@@ -514,21 +514,12 @@ class CTxMemPool
514
514
* `mempool.cs` whenever adding transactions to the mempool and whenever
515
515
* changing the chain tip. It's necessary to keep both mutexes locked until
516
516
* the mempool is consistent with the new chain tip and fully populated.
517
- *
518
- * @par Consistency bug
519
- *
520
- * The second guarantee above is not currently enforced, but
521
- * https://github.com/bitcoin/bitcoin/pull/14193 will fix it. No known code
522
- * in bitcoin currently depends on second guarantee, but it is important to
523
- * fix for third party code that needs be able to frequently poll the
524
- * mempool without locking `cs_main` and without encountering missing
525
- * transactions during reorgs.
526
517
*/
527
518
mutable RecursiveMutex cs;
528
519
indexed_transaction_set mapTx GUARDED_BY (cs);
529
520
530
521
using txiter = indexed_transaction_set::nth_index<0 >::type::const_iterator;
531
- std::vector<std::pair<uint256, txiter> > vTxHashes; // !< All tx witness hashes/entries in mapTx, in random order
522
+ std::vector<std::pair<uint256, txiter>> vTxHashes GUARDED_BY (cs) ; // !< All tx witness hashes/entries in mapTx, in random order
532
523
533
524
struct CompareIteratorByHash {
534
525
bool operator ()(const txiter &a, const txiter &b) const {
@@ -583,10 +574,10 @@ class CTxMemPool
583
574
void addUnchecked (const CTxMemPoolEntry& entry, bool validFeeEstimate = true ) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
584
575
void addUnchecked (const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true ) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
585
576
586
- void removeRecursive (const CTransaction & tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
587
- void removeForReorg (const CCoinsViewCache * pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
588
- void removeConflicts (const CTransaction & tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
589
- void removeForBlock (const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight);
577
+ void removeRecursive (const CTransaction& tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs );
578
+ void removeForReorg (const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
579
+ void removeConflicts (const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
580
+ void removeForBlock (const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs) ;
590
581
591
582
void clear ();
592
583
void _clear () EXCLUSIVE_LOCKS_REQUIRED(cs); // lock free
@@ -599,7 +590,7 @@ class CTxMemPool
599
590
* Check that none of this transactions inputs are in the mempool, and thus
600
591
* the tx is not dependent on other mempool transactions to be included in a block.
601
592
*/
602
- bool HasNoInputsOf (const CTransaction& tx) const ;
593
+ bool HasNoInputsOf (const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs) ;
603
594
604
595
/* * Affect CreateNewBlock prioritisation of transactions */
605
596
void PrioritiseTransaction (const uint256& hash, const CAmount& nFeeDelta);
@@ -633,7 +624,7 @@ class CTxMemPool
633
624
* for). Note: vHashesToUpdate should be the set of transactions from the
634
625
* disconnected block that have been accepted back into the mempool.
635
626
*/
636
- void UpdateTransactionsFromBlock (const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
627
+ void UpdateTransactionsFromBlock (const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
637
628
638
629
/* * Try to calculate all in-mempool ancestors of entry.
639
630
* (these are all calculated including the tx itself)
@@ -664,10 +655,10 @@ class CTxMemPool
664
655
* pvNoSpendsRemaining, if set, will be populated with the list of outpoints
665
656
* which are not in mempool which no longer have any spends in this mempool.
666
657
*/
667
- void TrimToSize (size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining= nullptr );
658
+ void TrimToSize (size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining = nullptr ) EXCLUSIVE_LOCKS_REQUIRED(cs );
668
659
669
660
/* * Expire all transaction (and their dependencies) in the mempool older than time. Return the number of removed transactions. */
670
- int Expire (int64_t time);
661
+ int Expire (int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs) ;
671
662
672
663
/* *
673
664
* Calculate the ancestor and descendant count for the given transaction.
0 commit comments