diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index b8ec3aed84..2f5f8285ae 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -102,10 +102,6 @@ public: */ virtual bool processNewBlock(const std::shared_ptr& block, bool* new_block) = 0; - //! Return the number of transaction updates in the mempool, - //! used to decide whether to make a new block template. - virtual unsigned int getTransactionsUpdated() = 0; - //! Get internal node context. Useful for RPC and testing, //! but not accessible across processes. virtual node::NodeContext* context() { return nullptr; } diff --git a/src/ipc/capnp/mining.capnp b/src/ipc/capnp/mining.capnp index 3d9b12e734..6f9f2fe31c 100644 --- a/src/ipc/capnp/mining.capnp +++ b/src/ipc/capnp/mining.capnp @@ -19,7 +19,6 @@ interface Mining $Proxy.wrap("interfaces::Mining") { waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64) -> (result: Common.BlockRef); createNewBlock @4 (options: BlockCreateOptions) -> (result: BlockTemplate); processNewBlock @5 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool); - getTransactionsUpdated @6 (context :Proxy.Context) -> (result: UInt32); } interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") { diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 7a98f402b9..a5a62c2654 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -984,11 +984,6 @@ public: return chainman().ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/new_block); } - unsigned int getTransactionsUpdated() override - { - return context()->mempool->GetTransactionsUpdated(); - } - std::unique_ptr createNewBlock(const BlockCreateOptions& options) override { BlockAssembler::Options assemble_options{options}; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 1870636ab1..3b6435f3f1 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -743,6 +743,7 @@ static RPCHelpMan getblocktemplate() } static unsigned int nTransactionsUpdatedLast; + const CTxMemPool& mempool = EnsureMemPool(node); if (!lpval.isNull()) { @@ -773,7 +774,7 @@ static RPCHelpMan getblocktemplate() tip = miner.waitTipChanged(hashWatchedChain, checktxtime).hash; // Timeout: Check transactions for update // without holding the mempool lock to avoid deadlocks - if (miner.getTransactionsUpdated() != nTransactionsUpdatedLastLP) + if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP) break; checktxtime = std::chrono::seconds(10); } @@ -804,13 +805,13 @@ static RPCHelpMan getblocktemplate() static int64_t time_start; static std::unique_ptr block_template; if (!pindexPrev || pindexPrev->GetBlockHash() != tip || - (miner.getTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - time_start > 5)) + (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - time_start > 5)) { // Clear pindexPrev so future calls make a new block, despite any failures from here on pindexPrev = nullptr; // Store the pindexBest used before createNewBlock, to avoid races - nTransactionsUpdatedLast = miner.getTransactionsUpdated(); + nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrevNew = chainman.m_blockman.LookupBlockIndex(tip); time_start = GetTime();