From a401a02ddb3fb045d998cf650292cab3b3ebfd58 Mon Sep 17 00:00:00 2001 From: Antonio Juarez Date: Mon, 7 Apr 2014 16:02:15 +0100 Subject: Improvements in JSON RPC --- src/cryptonote_core/blockchain_storage.h | 16 +--------------- src/cryptonote_core/cryptonote_format_utils.h | 2 +- src/cryptonote_core/miner.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 18 deletions(-) (limited to 'src/cryptonote_core') diff --git a/src/cryptonote_core/blockchain_storage.h b/src/cryptonote_core/blockchain_storage.h index 5a3ff3d84..1ea5e29ea 100644 --- a/src/cryptonote_core/blockchain_storage.h +++ b/src/cryptonote_core/blockchain_storage.h @@ -63,9 +63,6 @@ namespace cryptonote bool get_blocks(uint64_t start_offset, size_t count, std::list& blocks, std::list& txs); bool get_blocks(uint64_t start_offset, size_t count, std::list& blocks); bool get_alternative_blocks(std::list& blocks); - //bool get_orphaned_blocks(std::list& orphaned_by_prev_id, std::list& orphaned_by_tx); - //size_t get_orphaned_by_prev_blocks_count(); - //size_t get_orphaned_by_tx_blocks_count(); size_t get_alternative_blocks_count(); crypto::hash get_block_id_by_height(uint64_t height); bool get_block_by_hash(const crypto::hash &h, block &blk); @@ -87,7 +84,6 @@ namespace cryptonote crypto::hash get_tail_id(uint64_t& height); difficulty_type get_difficulty_for_next_block(); bool add_new_block(const block& bl_, block_verification_context& bvc); - bool reset_and_set_genesis_block(const block& b); bool create_block_template(block& b, const account_public_address& miner_address, difficulty_type& di, uint64_t& height, const blobdata& ex_nonce); bool have_block(const crypto::hash& id); @@ -97,11 +93,9 @@ namespace cryptonote bool find_blockchain_supplement(const std::list& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp); bool find_blockchain_supplement(const std::list& qblock_ids, uint64_t& starter_offset); bool find_blockchain_supplement(const std::list& qblock_ids, std::list > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count); - //bool get_chain_entry(const NOTIFY_REQUEST_CHAIN_ENTRY::request& req, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp); bool handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NOTIFY_RESPONSE_GET_OBJECTS::request& rsp); bool handle_get_objects(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); bool get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); - //bool get_outs_for_amounts(uint64_t amount, std::vector >& keys, std::map& txs); bool get_backward_blocks_sizes(size_t from_height, std::vector& sz, size_t count); bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector& indexs); bool store_blockchain(); @@ -111,6 +105,7 @@ namespace cryptonote bool check_tx_inputs(const transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id); uint64_t get_current_comulative_blocksize_limit(); bool is_storing_blockchain(){return m_is_blockchain_storing;} + uint64_t block_difficulty(size_t i); template bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) @@ -191,9 +186,6 @@ namespace cryptonote std::atomic m_is_in_checkpoint_zone; std::atomic m_is_blockchain_storing; - - - bool switch_to_alternative_blockchain(std::list& alt_chain); bool pop_block_from_blockchain(); bool purge_block_data_from_blockchain(const block& b, size_t processed_tx_count); @@ -203,26 +195,20 @@ namespace cryptonote bool handle_block_to_main_chain(const block& bl, block_verification_context& bvc); bool handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc); bool handle_alternative_block(const block& b, const crypto::hash& id, block_verification_context& bvc); - //bool handle_block_as_orphaned(const block& b, const crypto::hash& id, block_verification_context& bvc); difficulty_type get_next_difficulty_for_alternative_chain(const std::list& alt_chain, block_extended_info& bei); bool prevalidate_miner_transaction(const block& b, uint64_t height); bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins); bool validate_transaction(const block& b, uint64_t height, const transaction& tx); - //bool add_block_to_orphaned_by_tx(const block& bl, const crypto::hash& h); - //bool finish_forward_orphaned_chain(std::list< orphans_indexed_container::index::type::iterator >& orph_chain); bool rollback_blockchain_switching(std::list& original_chain, size_t rollback_height); bool add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height); bool push_transaction_to_global_outs_index(const transaction& tx, const crypto::hash& tx_id, std::vector& global_indexes); bool pop_transaction_from_global_index(const transaction& tx, const crypto::hash& tx_id); - //bool review_orphaned_blocks_with_new_block_id(const crypto::hash& id, bool main_chain); - //void review_orphaned_blocks_finisher(); bool get_last_n_blocks_sizes(std::vector& sz, size_t count); bool add_out_to_get_random_outs(std::vector >& amount_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount& result_outs, uint64_t amount, size_t i); bool is_tx_spendtime_unlocked(uint64_t unlock_time); bool add_block_as_invalid(const block& bl, const crypto::hash& h); bool add_block_as_invalid(const block_extended_info& bei, const crypto::hash& h); size_t find_end_of_allowed_index(const std::vector >& amount_outs); - uint64_t block_difficulty(size_t i); bool check_block_timestamp_main(const block& b); bool check_block_timestamp(std::vector timestamps, const block& b); uint64_t get_adjusted_time(); diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index 8f42b807a..554e466cc 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -36,7 +36,7 @@ namespace cryptonote uint64_t amount; //money account_public_address addr; //destination address - tx_destination_entry() { } + tx_destination_entry() : amount(0), addr(AUTO_VAL_INIT(addr)) { } tx_destination_entry(uint64_t a, const account_public_address &ad) : amount(a), addr(ad) { } }; diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp index a882e1899..142c81f68 100644 --- a/src/cryptonote_core/miner.cpp +++ b/src/cryptonote_core/miner.cpp @@ -48,7 +48,8 @@ namespace cryptonote m_last_hr_merge_time(0), m_hashes(0), m_do_print_hashrate(false), - m_do_mining(false) + m_do_mining(false), + m_current_hash_rate(0) { } @@ -225,7 +226,10 @@ namespace cryptonote //----------------------------------------------------------------------------------------------------- uint64_t miner::get_speed() { - return m_current_hash_rate; + if(is_mining()) + return m_current_hash_rate; + else + return 0; } //----------------------------------------------------------------------------------------------------- void miner::send_stop_signal() -- cgit v1.2.3