From d17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 1 Jun 2017 13:29:51 +0100 Subject: Don't copy blockchain for coinbase_tx_sum Changed Blockchain::for_all_blocks() to for_blocks_range() Operate on blockchain in-place instead of building a copy first. --- src/cryptonote_core/cryptonote_core.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/cryptonote_core/cryptonote_core.cpp') diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 21b0b4ceb..ff8bbef64 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -713,12 +713,13 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- std::pair core::get_coinbase_tx_sum(const uint64_t start_offset, const size_t count) { - std::list 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 txs; std::list 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(emission_amount, total_fee_amount); -- cgit v1.2.3