Skip to content

Commit 81dfedd

Browse files
committed
refactor: update MAX_DISCONNECTED_TX_POOL from kb to bytes
1 parent 5b44784 commit 81dfedd

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/bench/disconnected_transactions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static ReorgTxns CreateBlocks(size_t num_not_shared)
7373

7474
static void Reorg(const ReorgTxns& reorg)
7575
{
76-
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000};
76+
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
7777
// Disconnect block
7878
const auto evicted = disconnectpool.AddTransactionsFromBlock(reorg.disconnected_txns);
7979
assert(evicted.empty());

src/kernel/disconnected_transactions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <unordered_map>
1515
#include <vector>
1616

17-
/** Maximum kilobytes for transactions to store for processing during reorg */
18-
static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20'000;
17+
/** Maximum bytes for transactions to store for processing during reorg */
18+
static const unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000};
1919
/**
2020
* DisconnectedBlockTransactions
2121

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_init, SnapshotTestSetup)
579579
// it will initialize instead of attempting to complete validation.
580580
//
581581
// Note that this is not a realistic use of DisconnectTip().
582-
DisconnectedBlockTransactions unused_pool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000};
582+
DisconnectedBlockTransactions unused_pool{MAX_DISCONNECTED_TX_POOL_BYTES};
583583
BlockValidationState unused_state;
584584
{
585585
LOCK2(::cs_main, bg_chainstate.MempoolMutex());

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ bool Chainstate::ActivateBestChainStep(BlockValidationState& state, CBlockIndex*
30583058

30593059
// Disconnect active blocks which are no longer in the best chain.
30603060
bool fBlocksDisconnected = false;
3061-
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000};
3061+
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
30623062
while (m_chain.Tip() && m_chain.Tip() != pindexFork) {
30633063
if (!DisconnectTip(state, &disconnectpool)) {
30643064
// This is likely a fatal error, but keep the mempool consistent,
@@ -3416,7 +3416,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
34163416

34173417
// ActivateBestChain considers blocks already in m_chain
34183418
// unconditionally valid already, so force disconnect away from it.
3419-
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_SIZE * 1000};
3419+
DisconnectedBlockTransactions disconnectpool{MAX_DISCONNECTED_TX_POOL_BYTES};
34203420
bool ret = DisconnectTip(state, &disconnectpool);
34213421
// DisconnectTip will add transactions to disconnectpool.
34223422
// Adjust the mempool to be consistent with the new tip, adding

0 commit comments

Comments
 (0)