mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
Merge bitcoin/bitcoin#23692: mining, refactor: add m_mempool.cs thread safety lock assertions
275e9390e1
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: ACK275e9390e1
. Thanks for catching and fixing this! Tree-SHA512: 1c6f1ad1bbd94ff391fc8ce1e3b95d88bd3db5db804a1a5ef4636e54b29f5801f79aa9ed753d34c9a79a58cf01c7ed890e7681ff1c7b0f16335dc062bbac31cc
This commit is contained in:
commit
eaf1c56502
1 changed files with 6 additions and 0 deletions
|
@ -251,6 +251,8 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
|
||||||
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
|
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
|
||||||
indexed_modified_transaction_set &mapModifiedTx)
|
indexed_modified_transaction_set &mapModifiedTx)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(m_mempool.cs);
|
||||||
|
|
||||||
int nDescendantsUpdated = 0;
|
int nDescendantsUpdated = 0;
|
||||||
for (CTxMemPool::txiter it : alreadyAdded) {
|
for (CTxMemPool::txiter it : alreadyAdded) {
|
||||||
CTxMemPool::setEntries descendants;
|
CTxMemPool::setEntries descendants;
|
||||||
|
@ -287,6 +289,8 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
|
||||||
// cached size/sigops/fee values that are not actually correct.
|
// cached size/sigops/fee values that are not actually correct.
|
||||||
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
|
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(m_mempool.cs);
|
||||||
|
|
||||||
assert(it != m_mempool.mapTx.end());
|
assert(it != m_mempool.mapTx.end());
|
||||||
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it);
|
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.
|
// transaction package to work on next.
|
||||||
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
|
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(m_mempool.cs);
|
||||||
|
|
||||||
// mapModifiedTx will store sorted packages after they are modified
|
// mapModifiedTx will store sorted packages after they are modified
|
||||||
// because some of their txs are already in the block
|
// because some of their txs are already in the block
|
||||||
indexed_modified_transaction_set mapModifiedTx;
|
indexed_modified_transaction_set mapModifiedTx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue