@@ -156,11 +156,11 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
156
156
return true ;
157
157
}
158
158
159
- static UniValue generateBlocks (ChainstateManager& chainman, const CTxMemPool& mempool , const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
159
+ static UniValue generateBlocks (ChainstateManager& chainman, Mining& miner , const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
160
160
{
161
161
UniValue blockHashes (UniValue::VARR);
162
162
while (nGenerate > 0 && !chainman.m_interrupt ) {
163
- std::unique_ptr<CBlockTemplate> pblocktemplate (BlockAssembler{chainman. ActiveChainstate (), &mempool}. CreateNewBlock (coinbase_script));
163
+ std::unique_ptr<CBlockTemplate> pblocktemplate (miner. createNewBlock (coinbase_script));
164
164
if (!pblocktemplate.get ())
165
165
throw JSONRPCError (RPC_INTERNAL_ERROR, " Couldn't create new block" );
166
166
@@ -241,10 +241,10 @@ static RPCHelpMan generatetodescriptor()
241
241
}
242
242
243
243
NodeContext& node = EnsureAnyNodeContext (request.context );
244
- const CTxMemPool& mempool = EnsureMemPool (node);
244
+ Mining& miner = EnsureMining (node);
245
245
ChainstateManager& chainman = EnsureChainman (node);
246
246
247
- return generateBlocks (chainman, mempool , coinbase_script, num_blocks, max_tries);
247
+ return generateBlocks (chainman, miner , coinbase_script, num_blocks, max_tries);
248
248
},
249
249
};
250
250
}
@@ -287,12 +287,12 @@ static RPCHelpMan generatetoaddress()
287
287
}
288
288
289
289
NodeContext& node = EnsureAnyNodeContext (request.context );
290
- const CTxMemPool& mempool = EnsureMemPool (node);
290
+ Mining& miner = EnsureMining (node);
291
291
ChainstateManager& chainman = EnsureChainman (node);
292
292
293
293
CScript coinbase_script = GetScriptForDestination (destination);
294
294
295
- return generateBlocks (chainman, mempool , coinbase_script, num_blocks, max_tries);
295
+ return generateBlocks (chainman, miner , coinbase_script, num_blocks, max_tries);
296
296
},
297
297
};
298
298
}
@@ -373,7 +373,7 @@ static RPCHelpMan generateblock()
373
373
{
374
374
LOCK (cs_main);
375
375
376
- std::unique_ptr<CBlockTemplate> blocktemplate (BlockAssembler{chainman. ActiveChainstate (), nullptr }. CreateNewBlock (coinbase_script)) ;
376
+ std::unique_ptr<CBlockTemplate> blocktemplate{miner. createNewBlock (coinbase_script, /* use_mempool= */ false )} ;
377
377
if (!blocktemplate) {
378
378
throw JSONRPCError (RPC_INTERNAL_ERROR, " Couldn't create new block" );
379
379
}
@@ -671,7 +671,6 @@ static RPCHelpMan getblocktemplate()
671
671
std::string strMode = " template" ;
672
672
UniValue lpval = NullUniValue;
673
673
std::set<std::string> setClientRules;
674
- Chainstate& active_chainstate = chainman.ActiveChainstate ();
675
674
if (!request.params [0 ].isNull ())
676
675
{
677
676
const UniValue& oparam = request.params [0 ].get_obj ();
@@ -810,18 +809,19 @@ static RPCHelpMan getblocktemplate()
810
809
// Clear pindexPrev so future calls make a new block, despite any failures from here on
811
810
pindexPrev = nullptr ;
812
811
813
- // Store the pindexBest used before CreateNewBlock , to avoid races
812
+ // Store the pindexBest used before createNewBlock , to avoid races
814
813
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated ();
815
814
CBlockIndex* pindexPrevNew = chainman.m_blockman .LookupBlockIndex (miner.getTipHash ());
816
815
time_start = GetTime ();
817
816
818
817
// Create new block
819
818
CScript scriptDummy = CScript () << OP_TRUE;
820
- pblocktemplate = BlockAssembler{active_chainstate, &mempool}. CreateNewBlock (scriptDummy);
821
- if (!pblocktemplate)
819
+ pblocktemplate = miner. createNewBlock (scriptDummy);
820
+ if (!pblocktemplate) {
822
821
throw JSONRPCError (RPC_OUT_OF_MEMORY, " Out of memory" );
822
+ }
823
823
824
- // Need to update only after we know CreateNewBlock succeeded
824
+ // Need to update only after we know createNewBlock succeeded
825
825
pindexPrev = pindexPrevNew;
826
826
}
827
827
CHECK_NONFATAL (pindexPrev);
0 commit comments