refactor: update MAX_DISCONNECTED_TX_POOL from kb to bytes

This commit is contained in:
ismaelsadeeq 2023-09-25 13:00:52 +01:00
parent 5b4478418b
commit 81dfeddea7
4 changed files with 6 additions and 6 deletions

View file

@ -73,7 +73,7 @@ static ReorgTxns CreateBlocks(size_t num_not_shared)
static void Reorg(const ReorgTxns& reorg) static void Reorg(const ReorgTxns& reorg)
{ {
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000}; DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
// Disconnect block // Disconnect block
const auto evicted = disconnectpool.AddTransactionsFromBlock(reorg.disconnected_txns); const auto evicted = disconnectpool.AddTransactionsFromBlock(reorg.disconnected_txns);
assert(evicted.empty()); assert(evicted.empty());

View file

@ -14,8 +14,8 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
/** Maximum kilobytes for transactions to store for processing during reorg */ /** Maximum bytes for transactions to store for processing during reorg */
static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20'000; static const unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000};
/** /**
* DisconnectedBlockTransactions * DisconnectedBlockTransactions

View file

@ -579,7 +579,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_init, SnapshotTestSetup)
// it will initialize instead of attempting to complete validation. // it will initialize instead of attempting to complete validation.
// //
// Note that this is not a realistic use of DisconnectTip(). // Note that this is not a realistic use of DisconnectTip().
DisconnectedBlockTransactions unused_pool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000}; DisconnectedBlockTransactions unused_pool{MAX_DISCONNECTED_TX_POOL_BYTES};
BlockValidationState unused_state; BlockValidationState unused_state;
{ {
LOCK2(::cs_main, bg_chainstate.MempoolMutex()); LOCK2(::cs_main, bg_chainstate.MempoolMutex());

View file

@ -3058,7 +3058,7 @@ bool Chainstate::ActivateBestChainStep(BlockValidationState& state, CBlockIndex*
// Disconnect active blocks which are no longer in the best chain. // Disconnect active blocks which are no longer in the best chain.
bool fBlocksDisconnected = false; bool fBlocksDisconnected = false;
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000}; DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
while (m_chain.Tip() && m_chain.Tip() != pindexFork) { while (m_chain.Tip() && m_chain.Tip() != pindexFork) {
if (!DisconnectTip(state, &disconnectpool)) { if (!DisconnectTip(state, &disconnectpool)) {
// This is likely a fatal error, but keep the mempool consistent, // This is likely a fatal error, but keep the mempool consistent,
@ -3416,7 +3416,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
// ActivateBestChain considers blocks already in m_chain // ActivateBestChain considers blocks already in m_chain
// unconditionally valid already, so force disconnect away from it. // unconditionally valid already, so force disconnect away from it.
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000}; DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
bool ret = DisconnectTip(state, &disconnectpool); bool ret = DisconnectTip(state, &disconnectpool);
// DisconnectTip will add transactions to disconnectpool. // DisconnectTip will add transactions to disconnectpool.
// Adjust the mempool to be consistent with the new tip, adding // Adjust the mempool to be consistent with the new tip, adding