Skip to content

Commit

Permalink
Make DynamicMemoryUsage/addTransaction private
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Sep 6, 2023
1 parent 4511f27 commit 4703d4a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/kernel/disconnected_transactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ struct DisconnectedBlockTransactions {
using Queue = decltype(queuedTx);
std::unordered_map<uint256, Queue::iterator, SaltedTxidHasher> 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
Expand All @@ -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<CTransactionRef> addTransactionsForBlock(const CBlock& block)
{
Expand Down

0 comments on commit 4703d4a

Please sign in to comment.