Skip to content

Commit cc5739b

Browse files
committed
miner: Make UpdatePackagesForAdded static
Since UpdatePackagesForAdded is a helper function that's only used in addPackageTxs we can make it static and avoid the unnecessary interface and in-header lock annotation.
1 parent f024578 commit cc5739b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/node/miner.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,19 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
232232
}
233233
}
234234

235-
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
236-
indexed_modified_transaction_set &mapModifiedTx)
235+
/** Add descendants of given transactions to mapModifiedTx with ancestor
236+
* state updated assuming given transactions are inBlock. Returns number
237+
* of updated descendants. */
238+
static int UpdatePackagesForAdded(const CTxMemPool& mempool,
239+
const CTxMemPool::setEntries& alreadyAdded,
240+
indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
237241
{
238-
AssertLockHeld(m_mempool.cs);
242+
AssertLockHeld(mempool.cs);
239243

240244
int nDescendantsUpdated = 0;
241245
for (CTxMemPool::txiter it : alreadyAdded) {
242246
CTxMemPool::setEntries descendants;
243-
m_mempool.CalculateDescendants(it, descendants);
247+
mempool.CalculateDescendants(it, descendants);
244248
// Insert all descendants (not yet in block) into the modified set
245249
for (CTxMemPool::txiter desc : descendants) {
246250
if (alreadyAdded.count(desc)) {
@@ -421,7 +425,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
421425
++nPackagesSelected;
422426

423427
// Update transactions that depend on each of these
424-
nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx);
428+
nDescendantsUpdated += UpdatePackagesForAdded(m_mempool, ancestors, mapModifiedTx);
425429
}
426430
}
427431
} // namespace node

src/node/miner.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ class BlockAssembler
191191
bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
192192
/** Sort the package in an order that is valid to appear in a block */
193193
void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
194-
/** Add descendants of given transactions to mapModifiedTx with ancestor
195-
* state updated assuming given transactions are inBlock. Returns number
196-
* of updated descendants. */
197-
int UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
198194
};
199195

200196
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);

0 commit comments

Comments
 (0)