diff options
| author | Howard Chu <hyc@symas.com> | 2017-06-01 13:29:51 +0100 |
|---|---|---|
| committer | Howard Chu <hyc@symas.com> | 2017-06-01 14:14:24 +0100 |
| commit | d17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7 (patch) | |
| tree | 74598f10a771ee39e05778a20d1be805727169e0 /src/cryptonote_core/cryptonote_core.cpp | |
| parent | 8fbbefb8db3258e20f09efde1060e7a147a8887c (diff) | |
| download | monzero-core-d17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7.tar.gz monzero-core-d17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7.tar.xz monzero-core-d17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7.zip | |
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.
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
| -rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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<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); |
