Skip to content

Commit eaf1c56

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23692: mining, refactor: add m_mempool.cs thread safety lock assertions
275e939 mining, refactor: add m_mempool.cs thread safety lock assertions (Jon Atack) Pull request description: in src/node/miner to - BlockAssembler::addPackageTxs() - BlockAssembler::SkipMapTxEntry() - BlockAssembler::UpdatePackagesForAdded() These functions have thread safety lock annotations in their declarations but are missing the corresponding run-time lock assertions in their definitions. Per doc/developer-notes.md: "Combine annotations in function declarations with run-time asserts in function definitions." ACKs for top commit: shaavan: ACK 275e939. Thanks for catching and fixing this! Tree-SHA512: 1c6f1ad1bbd94ff391fc8ce1e3b95d88bd3db5db804a1a5ef4636e54b29f5801f79aa9ed753d34c9a79a58cf01c7ed890e7681ff1c7b0f16335dc062bbac31cc
2 parents 13f4185 + 275e939 commit eaf1c56

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node/miner.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
251251
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
252252
indexed_modified_transaction_set &mapModifiedTx)
253253
{
254+
AssertLockHeld(m_mempool.cs);
255+
254256
int nDescendantsUpdated = 0;
255257
for (CTxMemPool::txiter it : alreadyAdded) {
256258
CTxMemPool::setEntries descendants;
@@ -287,6 +289,8 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
287289
// cached size/sigops/fee values that are not actually correct.
288290
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
289291
{
292+
AssertLockHeld(m_mempool.cs);
293+
290294
assert(it != m_mempool.mapTx.end());
291295
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it);
292296
}
@@ -314,6 +318,8 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve
314318
// transaction package to work on next.
315319
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
316320
{
321+
AssertLockHeld(m_mempool.cs);
322+
317323
// mapModifiedTx will store sorted packages after they are modified
318324
// because some of their txs are already in the block
319325
indexed_modified_transaction_set mapModifiedTx;

0 commit comments

Comments
 (0)