diff options
author | Howard Chu <hyc@symas.com> | 2017-05-31 19:11:56 +0100 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2017-06-01 17:34:03 +0100 |
commit | 5414970dcd05e77a8734f142969c1c805f056f52 (patch) | |
tree | e102846c2c56b8833156fc92e920411bdb1fbcf1 /src/cryptonote_core/tx_pool.cpp | |
parent | Merge pull request #2053 (diff) | |
download | monero-5414970dcd05e77a8734f142969c1c805f056f52.tar.xz |
Speedup print_pool_stats
Since we're just counting txs, there's no reason to deserialize all the blobs.
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 30aed50f9..ebf170c8c 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -546,6 +546,31 @@ namespace cryptonote }); } //------------------------------------------------------------------ + void tx_memory_pool::get_transaction_stats(struct txpool_stats& stats) const + { + CRITICAL_REGION_LOCAL(m_transactions_lock); + CRITICAL_REGION_LOCAL1(m_blockchain); + const uint64_t now = time(NULL); + stats.txs_total = m_blockchain.get_txpool_tx_count(); + m_blockchain.for_all_txpool_txes([&stats, now](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){ + stats.bytes_total += meta.blob_size; + if (!stats.bytes_min || meta.blob_size < stats.bytes_min) + stats.bytes_min = meta.blob_size; + if (meta.blob_size > stats.bytes_max) + stats.bytes_max = meta.blob_size; + if (!meta.relayed) + stats.num_not_relayed++; + stats.fee_total += meta.fee; + if (!stats.oldest || meta.receive_time < stats.oldest) + stats.oldest = meta.receive_time; + if (meta.receive_time < now - 600) + stats.num_10m++; + if (meta.last_failed_height) + stats.num_failing++; + return true; + }); + } + //------------------------------------------------------------------ //TODO: investigate whether boolean return is appropriate bool tx_memory_pool::get_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos) const { |