aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp28
-rw-r--r--src/cryptonote_core/cryptonote_core.h7
2 files changed, 35 insertions, 0 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 149fb09df..9a44d9d3f 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -616,6 +616,34 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
+ std::pair<uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count)
+ {
+ std::list<block> blocks;
+ 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_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 std::pair<uint64_t, uint64_t>(emission_amount, total_fee_amount);
+ }
+ //-----------------------------------------------------------------------------------------------
bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const
{
std::unordered_set<crypto::key_image> ki;
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 6727d6b04..407e89197 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -600,6 +600,13 @@ namespace cryptonote
*/
size_t get_block_sync_size() const { return block_sync_size; }
+ /**
+ * @brief get the sum of coinbase tx amounts between blocks
+ *
+ * @return the number of blocks to sync in one go
+ */
+ std::pair<uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count);
+
private:
/**