mirror of
https://github.com/monero-project/monero.git
synced 2025-08-11 14:10:21 -04:00
Speedup print_pool_stats
Since we're just counting txs, there's no reason to deserialize all the blobs.
This commit is contained in:
parent
8fbbefb8db
commit
5414970dcd
8 changed files with 112 additions and 34 deletions
|
@ -1046,6 +1046,12 @@ namespace cryptonote
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::get_pool_transaction_stats(struct txpool_stats& stats) const
|
||||
{
|
||||
m_mempool.get_transaction_stats(stats);
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::get_pool_transaction(const crypto::hash &id, cryptonote::blobdata& tx) const
|
||||
{
|
||||
return m_mempool.get_transaction(id, tx);
|
||||
|
|
|
@ -410,6 +410,13 @@ namespace cryptonote
|
|||
*/
|
||||
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs) const;
|
||||
|
||||
/**
|
||||
* @copydoc tx_memory_pool::get_transactions
|
||||
*
|
||||
* @note see tx_memory_pool::get_transactions
|
||||
*/
|
||||
bool get_pool_transaction_stats(struct txpool_stats& stats) const;
|
||||
|
||||
/**
|
||||
* @copydoc tx_memory_pool::get_transaction
|
||||
*
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -242,6 +242,13 @@ namespace cryptonote
|
|||
*/
|
||||
void get_transaction_hashes(std::vector<crypto::hash>& txs) const;
|
||||
|
||||
/**
|
||||
* @brief get a summary statistics of all transaction hashes in the pool
|
||||
*
|
||||
* @param stats return-by-reference the pool statistics
|
||||
*/
|
||||
void get_transaction_stats(struct txpool_stats& stats) const;
|
||||
|
||||
/**
|
||||
* @brief get information about all transactions and key images in the pool
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue