diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-04-17 11:04:01 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-16 12:44:33 +0000 |
commit | 82d1b74500aa7ffab47f428f9ca26bb43cc2d8af (patch) | |
tree | 4bf2f0630275fc66125c0db19853ce32aca12ac7 /src/cryptonote_core/blockchain.h | |
parent | Merge pull request #4191 (diff) | |
download | monero-82d1b74500aa7ffab47f428f9ca26bb43cc2d8af.tar.xz |
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.
Diffstat (limited to 'src/cryptonote_core/blockchain.h')
-rw-r--r-- | src/cryptonote_core/blockchain.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index d95c8ed15..238867c18 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -1052,6 +1052,15 @@ namespace cryptonote std::atomic<bool> m_cancel; + // block template cache + block m_btc; + account_public_address m_btc_address; + blobdata m_btc_nonce; + difficulty_type m_btc_difficulty; + uint64_t m_btc_pool_cookie; + uint64_t m_btc_expected_reward; + bool m_btc_valid; + /** * @brief collects the keys for all outputs being "spent" as an input * @@ -1407,5 +1416,17 @@ namespace cryptonote * that implicit data. */ bool expand_transaction_2(transaction &tx, const crypto::hash &tx_prefix_hash, const std::vector<std::vector<rct::ctkey>> &pubkeys); + + /** + * @brief invalidates any cached block template + */ + void invalidate_block_template_cache(); + + /** + * @brief stores a new cached block template + * + * At some point, may be used to push an update to miners + */ + void cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t expected_reward, uint64_t pool_cookie); }; } // namespace cryptonote |