diff options
author | Dion Ahmetaj <Dion Ahmetaj> | 2016-10-10 19:55:18 -0400 |
---|---|---|
committer | Dion Ahmetaj <Dion Ahmetaj> | 2016-10-10 19:55:18 -0400 |
commit | 7db29d6903fe24eabaaf3b3afc364b6924d5b463 (patch) | |
tree | d754fd808175986db9a77aec743d89b7fced914b /src/cryptonote_core | |
parent | changed params from start/end index to height/count (diff) | |
download | monero-7db29d6903fe24eabaaf3b3afc364b6924d5b463.tar.xz |
print_coinbase_tx_sum now breaks output into fee and emission components
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 24 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index ecbc1067c..9a44d9d3f 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -616,18 +616,32 @@ namespace cryptonote return true; } //----------------------------------------------------------------------------------------------- - uint64_t core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count) + std::pair<uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count) { std::list<block> blocks; - uint64_t coinbase_tx_sum = 0; - uint64_t current_index = start_offset; + std::list<transaction> txs; + std::list<crypto::hash> missed_txs; + uint64_t coinbase_amount = 0; + uint64_t emission_amount = 0; + uint64_t total_fee_amount = 0; + uint64_t tx_fee_amount = 0; this->get_blocks(start_offset, count, blocks); BOOST_FOREACH(auto& b, blocks) { - coinbase_tx_sum += get_outs_money_amount(b.miner_tx); + coinbase_amount = get_outs_money_amount(b.miner_tx); + this->get_transactions(b.tx_hashes, txs, missed_txs); + BOOST_FOREACH(const auto& tx, txs) + { + tx_fee_amount += get_tx_fee(tx); + } + + emission_amount += coinbase_amount - tx_fee_amount; + total_fee_amount += tx_fee_amount; + coinbase_amount = 0; + tx_fee_amount = 0; } - return coinbase_tx_sum; + return std::pair<uint64_t, uint64_t>(emission_amount, total_fee_amount); } //----------------------------------------------------------------------------------------------- bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index c152e6a3f..407e89197 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -605,7 +605,7 @@ namespace cryptonote * * @return the number of blocks to sync in one go */ - uint64_t get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count); + std::pair<uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count); private: |