@@ -179,7 +179,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
179
179
// transaction (which in most cases can be a no-op).
180
180
fIncludeWitness = IsWitnessEnabled (pindexPrev, chainparams.GetConsensus ());
181
181
182
- addPackageTxs ();
182
+ int nPackagesSelected = 0 ;
183
+ int nDescendantsUpdated = 0 ;
184
+ addPackageTxs (nPackagesSelected, nDescendantsUpdated);
183
185
184
186
int64_t nTime1 = GetTimeMicros ();
185
187
@@ -215,7 +217,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
215
217
}
216
218
int64_t nTime2 = GetTimeMicros ();
217
219
218
- LogPrint (" bench" , " CreateNewBlock() packages: %.2fms, validity: %.2fms (total %.2fms)\n " , 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
220
+ LogPrint (" bench" , " CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n " , 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated , 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
219
221
220
222
return std::move (pblocktemplate);
221
223
}
@@ -289,16 +291,18 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
289
291
}
290
292
}
291
293
292
- void BlockAssembler::UpdatePackagesForAdded (const CTxMemPool::setEntries& alreadyAdded,
294
+ int BlockAssembler::UpdatePackagesForAdded (const CTxMemPool::setEntries& alreadyAdded,
293
295
indexed_modified_transaction_set &mapModifiedTx)
294
296
{
297
+ int nDescendantsUpdated = 0 ;
295
298
BOOST_FOREACH (const CTxMemPool::txiter it, alreadyAdded) {
296
299
CTxMemPool::setEntries descendants;
297
300
mempool.CalculateDescendants (it, descendants);
298
301
// Insert all descendants (not yet in block) into the modified set
299
302
BOOST_FOREACH (CTxMemPool::txiter desc, descendants) {
300
303
if (alreadyAdded.count (desc))
301
304
continue ;
305
+ ++nDescendantsUpdated;
302
306
modtxiter mit = mapModifiedTx.find (desc);
303
307
if (mit == mapModifiedTx.end ()) {
304
308
CTxMemPoolModifiedEntry modEntry (desc);
@@ -311,6 +315,7 @@ void BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alread
311
315
}
312
316
}
313
317
}
318
+ return nDescendantsUpdated;
314
319
}
315
320
316
321
// Skip entries in mapTx that are already in a block or are present
@@ -351,7 +356,7 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, CTxMemP
351
356
// Each time through the loop, we compare the best transaction in
352
357
// mapModifiedTxs with the next transaction in the mempool to decide what
353
358
// transaction package to work on next.
354
- void BlockAssembler::addPackageTxs ()
359
+ void BlockAssembler::addPackageTxs (int &nPackagesSelected, int &nDescendantsUpdated )
355
360
{
356
361
// mapModifiedTx will store sorted packages after they are modified
357
362
// because some of their txs are already in the block
@@ -474,8 +479,10 @@ void BlockAssembler::addPackageTxs()
474
479
mapModifiedTx.erase (sortedEntries[i]);
475
480
}
476
481
482
+ ++nPackagesSelected;
483
+
477
484
// Update transactions that depend on each of these
478
- UpdatePackagesForAdded (ancestors, mapModifiedTx);
485
+ nDescendantsUpdated += UpdatePackagesForAdded (ancestors, mapModifiedTx);
479
486
}
480
487
}
481
488
0 commit comments