mirror of
https://github.com/monero-project/monero.git
synced 2025-08-11 13:30:15 -04:00
Merge pull request #2063
d17c0fc2
Don't copy blockchain for coinbase_tx_sum (Howard Chu)
This commit is contained in:
commit
3d397325bf
7 changed files with 32 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue