From 4703d4ac629166baca3d7becba54f00ec4f36e17 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 6 Sep 2023 14:19:34 +0000 Subject: [PATCH] Make DynamicMemoryUsage/addTransaction private --- src/kernel/disconnected_transactions.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/kernel/disconnected_transactions.h b/src/kernel/disconnected_transactions.h index 1902cd7cb94d3..afbf2f6a180fe 100644 --- a/src/kernel/disconnected_transactions.h +++ b/src/kernel/disconnected_transactions.h @@ -35,18 +35,6 @@ struct DisconnectedBlockTransactions { using Queue = decltype(queuedTx); std::unordered_map iters_by_txid; -public: - // It's almost certainly a logic bug if we don't clear out queuedTx before - // destruction, as we add to it while disconnecting blocks, and then we - // need to re-process remaining transactions to ensure mempool consistency. - // For now, assert() that we've emptied out this object on destruction. - // This assert() can always be removed if the reorg-processing code were - // to be refactored such that this assumption is no longer true (for - // instance if there was some other way we cleaned up the mempool after a - // reorg, besides draining this object). - ~DisconnectedBlockTransactions() { assert(queuedTx.empty()); } - - DisconnectedBlockTransactions(unsigned int allowed_mem_usage) : m_allowed_mem_usage(allowed_mem_usage){} size_t DynamicMemoryUsage() const { // std::list has 3 pointers per entry @@ -60,6 +48,18 @@ struct DisconnectedBlockTransactions { iters_by_txid.emplace(tx->GetHash(), it); cachedInnerUsage += RecursiveDynamicUsage(tx); } +public: + // It's almost certainly a logic bug if we don't clear out queuedTx before + // destruction, as we add to it while disconnecting blocks, and then we + // need to re-process remaining transactions to ensure mempool consistency. + // For now, assert() that we've emptied out this object on destruction. + // This assert() can always be removed if the reorg-processing code were + // to be refactored such that this assumption is no longer true (for + // instance if there was some other way we cleaned up the mempool after a + // reorg, besides draining this object). + ~DisconnectedBlockTransactions() { assert(queuedTx.empty()); } + + DisconnectedBlockTransactions(unsigned int allowed_mem_usage) : m_allowed_mem_usage(allowed_mem_usage){} [[nodiscard]] std::list addTransactionsForBlock(const CBlock& block) {