Skip to content

Commit 9a47852

Browse files
committed
Remove getTransactionsUpdated() from mining interface
It's unnecessary to expose it via this interface.
1 parent bfc4e02 commit 9a47852

File tree

4 files changed

+4
-13
lines changed

4 files changed

+4
-13
lines changed

src/interfaces/mining.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ class Mining
102102
*/
103103
virtual bool processNewBlock(const std::shared_ptr<const CBlock>& block, bool* new_block) = 0;
104104

105-
//! Return the number of transaction updates in the mempool,
106-
//! used to decide whether to make a new block template.
107-
virtual unsigned int getTransactionsUpdated() = 0;
108-
109105
//! Get internal node context. Useful for RPC and testing,
110106
//! but not accessible across processes.
111107
virtual node::NodeContext* context() { return nullptr; }

src/ipc/capnp/mining.capnp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
1919
waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64) -> (result: Common.BlockRef);
2020
createNewBlock @4 (options: BlockCreateOptions) -> (result: BlockTemplate);
2121
processNewBlock @5 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
22-
getTransactionsUpdated @6 (context :Proxy.Context) -> (result: UInt32);
2322
}
2423

2524
interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {

src/node/interfaces.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,6 @@ class MinerImpl : public Mining
984984
return chainman().ProcessNewBlock(block, /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/new_block);
985985
}
986986

987-
unsigned int getTransactionsUpdated() override
988-
{
989-
return context()->mempool->GetTransactionsUpdated();
990-
}
991-
992987
std::unique_ptr<BlockTemplate> createNewBlock(const BlockCreateOptions& options) override
993988
{
994989
BlockAssembler::Options assemble_options{options};

src/rpc/mining.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ static RPCHelpMan getblocktemplate()
743743
}
744744

745745
static unsigned int nTransactionsUpdatedLast;
746+
const CTxMemPool& mempool = EnsureMemPool(node);
746747

747748
if (!lpval.isNull())
748749
{
@@ -773,7 +774,7 @@ static RPCHelpMan getblocktemplate()
773774
tip = miner.waitTipChanged(hashWatchedChain, checktxtime).hash;
774775
// Timeout: Check transactions for update
775776
// without holding the mempool lock to avoid deadlocks
776-
if (miner.getTransactionsUpdated() != nTransactionsUpdatedLastLP)
777+
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP)
777778
break;
778779
checktxtime = std::chrono::seconds(10);
779780
}
@@ -804,13 +805,13 @@ static RPCHelpMan getblocktemplate()
804805
static int64_t time_start;
805806
static std::unique_ptr<BlockTemplate> block_template;
806807
if (!pindexPrev || pindexPrev->GetBlockHash() != tip ||
807-
(miner.getTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - time_start > 5))
808+
(mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - time_start > 5))
808809
{
809810
// Clear pindexPrev so future calls make a new block, despite any failures from here on
810811
pindexPrev = nullptr;
811812

812813
// Store the pindexBest used before createNewBlock, to avoid races
813-
nTransactionsUpdatedLast = miner.getTransactionsUpdated();
814+
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
814815
CBlockIndex* pindexPrevNew = chainman.m_blockman.LookupBlockIndex(tip);
815816
time_start = GetTime();
816817

0 commit comments

Comments
 (0)