core: cache block template where possible

This avoids constant rechecking of the same things each time
a miner asks for the block template. The tx pool maintains
a cookie to allow users to detect when the pool state changed,
which means the block template needs rebuilding.
This commit is contained in:
moneromooo-monero
2016-04-17 11:04:01 +01:00
parent b780cf4db1
commit 82d1b74500
4 changed files with 94 additions and 2 deletions
+9
View File
@@ -362,6 +362,13 @@ namespace cryptonote
*/
size_t validate(uint8_t version);
/**
* @brief return the cookie
*
* @return the cookie
*/
uint64_t cookie() const { return m_cookie; }
/**
* @brief get the cumulative txpool size in bytes
*
@@ -549,6 +556,8 @@ private:
//!< container for transactions organized by fee per size and receive time
sorted_tx_container m_txs_by_fee_and_receive_time;
std::atomic<uint64_t> m_cookie; //!< incremented at each change
/**
* @brief get an iterator to a transaction in the sorted container
*