aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-06-01 19:33:43 +0200
committerRiccardo Spagni <ric@spagni.net>2017-06-01 19:33:43 +0200
commit3d397325bf1c2de80812e6bdf039d4484617f29a (patch)
treed8b052da9ed7896d1d877665611c2056f5805818 /src/cryptonote_core/cryptonote_core.cpp
parent4a60e9e66ec0d5318b1edfc539b17e0f15a47a81 (diff)
parentd17c0fc2d0ae52260a93ec8985b7ebb7ad3cfea7 (diff)
downloadmonzero-core-3d397325bf1c2de80812e6bdf039d4484617f29a.tar.gz
monzero-core-3d397325bf1c2de80812e6bdf039d4484617f29a.tar.xz
monzero-core-3d397325bf1c2de80812e6bdf039d4484617f29a.zip
Merge pull request #2063
d17c0fc2 Don't copy blockchain for coinbase_tx_sum (Howard Chu)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp9
1 files changed, 6 insertions, 3 deletions
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);