diff options
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 4 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 6 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 9 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 7fb85ee76..6f2977c5b 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -4164,9 +4164,9 @@ bool Blockchain::for_all_key_images(std::function<bool(const crypto::key_image&) return m_db->for_all_key_images(f); } -bool Blockchain::for_all_blocks(std::function<bool(uint64_t, const crypto::hash&, const block&)> f) const +bool Blockchain::for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function<bool(uint64_t, const crypto::hash&, const block&)> f) const { - return m_db->for_all_blocks(f); + return m_db->for_blocks_range(h1, h2, f); } bool Blockchain::for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)> f) const diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 89efe5452..52172012c 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -790,13 +790,15 @@ namespace cryptonote bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const; /** - * @brief perform a check on all blocks in the blockchain + * @brief perform a check on all blocks in the blockchain in the given range * + * @param h1 the start height + * @param h2 the end height * @param std::function the check to perform, pass/fail * * @return false if any block fails the check, otherwise true */ - bool for_all_blocks(std::function<bool(uint64_t, const crypto::hash&, const block&)>) const; + bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function<bool(uint64_t, const crypto::hash&, const block&)>) const; /** * @brief perform a check on all transactions in the blockchain diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 2b3d09c45..c601c066c 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -713,12 +713,13 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- std::pair<uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const size_t count) { - std::list<block> blocks; uint64_t emission_amount = 0; uint64_t total_fee_amount = 0; - this->get_blocks(start_offset, count, blocks); - for(auto& b: blocks) + if (count) { + const uint64_t end = start_offset + count - 1; + m_blockchain_storage.for_blocks_range(start_offset, end, + [this, &emission_amount, &total_fee_amount](uint64_t, const crypto::hash& hash, const block& b){ std::list<transaction> txs; std::list<crypto::hash> missed_txs; uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx); @@ -731,6 +732,8 @@ namespace cryptonote emission_amount += coinbase_amount - tx_fee_amount; total_fee_amount += tx_fee_amount; + return true; + }); } return std::pair<uint64_t, uint64_t>(emission_amount, total_fee_amount); |