diff options
author | Jon Atack <jon@atack.com> | 2021-12-06 18:53:36 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-12-07 15:01:43 +0100 |
commit | 275e9390e1c84ac021b3c781ee239ad9ba7b78d4 (patch) | |
tree | 042308dc66407cc7a4995383b78e708c521eefa2 /src/node/miner.cpp | |
parent | 95fe477fd189ae30e76050b95280086d913e78c2 (diff) | |
download | bitcoin-275e9390e1c84ac021b3c781ee239ad9ba7b78d4.tar.xz |
mining, refactor: add m_mempool.cs thread safety lock assertions
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."
Diffstat (limited to 'src/node/miner.cpp')
-rw-r--r-- | src/node/miner.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 291a6e1d10..6e9bde84d8 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -251,6 +251,8 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set &mapModifiedTx) { + AssertLockHeld(m_mempool.cs); + int nDescendantsUpdated = 0; for (CTxMemPool::txiter it : alreadyAdded) { CTxMemPool::setEntries descendants; @@ -287,6 +289,8 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already // cached size/sigops/fee values that are not actually correct. bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) { + AssertLockHeld(m_mempool.cs); + assert(it != m_mempool.mapTx.end()); return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it); } @@ -314,6 +318,8 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve // transaction package to work on next. void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) { + AssertLockHeld(m_mempool.cs); + // mapModifiedTx will store sorted packages after they are modified // because some of their txs are already in the block indexed_modified_transaction_set mapModifiedTx; |