rpc: add a new RPC to get current txpool backlog (sizes and fees)

This commit is contained in:
moneromooo-monero 2017-08-26 16:23:31 +01:00
parent 335681896a
commit 55bec1f03d
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
7 changed files with 80 additions and 0 deletions

View file

@ -246,6 +246,12 @@ namespace cryptonote
return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs);
}
//-----------------------------------------------------------------------------------------------
bool core::get_txpool_backlog(std::vector<tx_backlog_entry>& backlog) const
{
m_mempool.get_transaction_backlog(backlog);
return true;
}
//-----------------------------------------------------------------------------------------------
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<transaction>& txs, std::list<crypto::hash>& missed_txs) const
{
return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs);

View file

@ -427,6 +427,13 @@ namespace cryptonote
*/
bool get_pool_transactions(std::list<transaction>& txs) const;
/**
* @copydoc tx_memory_pool::get_txpool_backlog
*
* @note see tx_memory_pool::get_txpool_backlog
*/
bool get_txpool_backlog(std::vector<tx_backlog_entry>& backlog) const;
/**
* @copydoc tx_memory_pool::get_transactions
*

View file

@ -553,6 +553,17 @@ namespace cryptonote
});
}
//------------------------------------------------------------------
void tx_memory_pool::get_transaction_backlog(std::vector<tx_backlog_entry>& backlog) const
{
CRITICAL_REGION_LOCAL(m_transactions_lock);
CRITICAL_REGION_LOCAL1(m_blockchain);
const uint64_t now = time(NULL);
m_blockchain.for_all_txpool_txes([&backlog, now](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){
backlog.push_back({meta.blob_size, meta.fee, meta.receive_time - now});
return true;
});
}
//------------------------------------------------------------------
void tx_memory_pool::get_transaction_stats(struct txpool_stats& stats) const
{
CRITICAL_REGION_LOCAL(m_transactions_lock);

View file

@ -242,6 +242,13 @@ namespace cryptonote
*/
void get_transaction_hashes(std::vector<crypto::hash>& txs) const;
/**
* @brief get (size, fee, receive time) for all transaction in the pool
*
* @param txs return-by-reference that data
*/
void get_transaction_backlog(std::vector<tx_backlog_entry>& backlog) const;
/**
* @brief get a summary statistics of all transaction hashes in the pool
*