File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ class Mining
41
41
*/
42
42
virtual std::unique_ptr<node::CBlockTemplate> createNewBlock (const CScript& script_pub_key, bool use_mempool = true ) = 0;
43
43
44
+ // ! Return the number of transaction updates in the mempool,
45
+ // ! used to decide whether to make a new block template.
46
+ virtual unsigned int getTransactionsUpdated () = 0;
47
+
44
48
/* *
45
49
* Check a block is completely valid from start to finish.
46
50
* Only works on top of our current best block.
Original file line number Diff line number Diff line change @@ -855,6 +855,11 @@ class MinerImpl : public Mining
855
855
return tip->GetBlockHash ();
856
856
}
857
857
858
+ unsigned int getTransactionsUpdated () override
859
+ {
860
+ return context ()->mempool ->GetTransactionsUpdated ();
861
+ }
862
+
858
863
bool testBlockValidity (BlockValidationState& state, const CBlock& block, bool check_merkle_root) override
859
864
{
860
865
LOCK (::cs_main);
Original file line number Diff line number Diff line change @@ -738,7 +738,6 @@ static RPCHelpMan getblocktemplate()
738
738
}
739
739
740
740
static unsigned int nTransactionsUpdatedLast;
741
- const CTxMemPool& mempool = EnsureMemPool (node);
742
741
743
742
if (!lpval.isNull ())
744
743
{
@@ -774,7 +773,7 @@ static RPCHelpMan getblocktemplate()
774
773
{
775
774
// Timeout: Check transactions for update
776
775
// without holding the mempool lock to avoid deadlocks
777
- if (mempool. GetTransactionsUpdated () != nTransactionsUpdatedLastLP)
776
+ if (miner. getTransactionsUpdated () != nTransactionsUpdatedLastLP)
778
777
break ;
779
778
checktxtime += std::chrono::seconds (10 );
780
779
}
@@ -804,13 +803,13 @@ static RPCHelpMan getblocktemplate()
804
803
static int64_t time_start;
805
804
static std::unique_ptr<CBlockTemplate> pblocktemplate;
806
805
if (!pindexPrev || pindexPrev->GetBlockHash () != miner.getTipHash () ||
807
- (mempool. GetTransactionsUpdated () != nTransactionsUpdatedLast && GetTime () - time_start > 5 ))
806
+ (miner. getTransactionsUpdated () != nTransactionsUpdatedLast && GetTime () - time_start > 5 ))
808
807
{
809
808
// Clear pindexPrev so future calls make a new block, despite any failures from here on
810
809
pindexPrev = nullptr ;
811
810
812
811
// Store the pindexBest used before createNewBlock, to avoid races
813
- nTransactionsUpdatedLast = mempool. GetTransactionsUpdated ();
812
+ nTransactionsUpdatedLast = miner. getTransactionsUpdated ();
814
813
CBlockIndex* pindexPrevNew = chainman.m_blockman .LookupBlockIndex (miner.getTipHash ());
815
814
time_start = GetTime ();
816
815
You can’t perform that action at this time.
0 commit comments