22
22
class TxOrphanage {
23
23
public:
24
24
/* * Add a new orphan transaction */
25
- bool AddTx (const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
25
+ bool AddTx (const CTransactionRef& tx, NodeId peer);
26
26
27
27
/* * Check if we already have an orphan transaction (by wtxid only) */
28
- bool HaveTx (const Wtxid& wtxid) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
28
+ bool HaveTx (const Wtxid& wtxid) const ;
29
29
30
30
/* * Extract a transaction from a peer's work set
31
31
* Returns nullptr if there are no transactions to work on.
32
32
* Otherwise returns the transaction reference, and removes
33
33
* it from the work set.
34
34
*/
35
- CTransactionRef GetTxToReconsider (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
35
+ CTransactionRef GetTxToReconsider (NodeId peer);
36
36
37
37
/* * Erase an orphan by wtxid */
38
- int EraseTx (const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
38
+ int EraseTx (const Wtxid& wtxid);
39
39
40
40
/* * Erase all orphans announced by a peer (eg, after that peer disconnects) */
41
- void EraseForPeer (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
41
+ void EraseForPeer (NodeId peer);
42
42
43
43
/* * Erase all orphans included in or invalidated by a new block */
44
- void EraseForBlock (const CBlock& block) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
44
+ void EraseForBlock (const CBlock& block);
45
45
46
46
/* * Limit the orphanage to the given maximum */
47
- void LimitOrphans (unsigned int max_orphans, FastRandomContext& rng) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
47
+ void LimitOrphans (unsigned int max_orphans, FastRandomContext& rng);
48
48
49
49
/* * Add any orphans that list a particular tx as a parent into the from peer's work set */
50
- void AddChildrenToWorkSet (const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex); ;
50
+ void AddChildrenToWorkSet (const CTransaction& tx);
51
51
52
52
/* * Does this peer have any work to do? */
53
- bool HaveTxToReconsider (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex); ;
53
+ bool HaveTxToReconsider (NodeId peer);
54
54
55
55
/* * Get all children that spend from this tx and were received from nodeid. Sorted from most
56
56
* recent to least recent. */
57
- std::vector<CTransactionRef> GetChildrenFromSamePeer (const CTransactionRef& parent, NodeId nodeid) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
57
+ std::vector<CTransactionRef> GetChildrenFromSamePeer (const CTransactionRef& parent, NodeId nodeid) const ;
58
58
59
59
/* * Get all children that spend from this tx but were not received from nodeid. Also return
60
60
* which peer provided each tx. */
61
- std::vector<std::pair<CTransactionRef, NodeId>> GetChildrenFromDifferentPeer (const CTransactionRef& parent, NodeId nodeid) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ;
61
+ std::vector<std::pair<CTransactionRef, NodeId>> GetChildrenFromDifferentPeer (const CTransactionRef& parent, NodeId nodeid) const ;
62
62
63
63
/* * Return how many entries exist in the orphange */
64
- size_t Size () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
64
+ size_t Size ()
65
65
{
66
- LOCK (m_mutex);
67
66
return m_orphans.size ();
68
67
}
69
68
70
69
protected:
71
- /* * Guards orphan transactions */
72
- mutable Mutex m_mutex;
73
-
74
70
struct OrphanTx {
75
71
CTransactionRef tx;
76
72
NodeId fromPeer;
@@ -80,10 +76,10 @@ class TxOrphanage {
80
76
81
77
/* * Map from wtxid to orphan transaction record. Limited by
82
78
* -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS */
83
- std::map<Wtxid, OrphanTx> m_orphans GUARDED_BY (m_mutex) ;
79
+ std::map<Wtxid, OrphanTx> m_orphans;
84
80
85
81
/* * Which peer provided the orphans that need to be reconsidered */
86
- std::map<NodeId, std::set<Wtxid>> m_peer_work_set GUARDED_BY (m_mutex) ;
82
+ std::map<NodeId, std::set<Wtxid>> m_peer_work_set;
87
83
88
84
using OrphanMap = decltype (m_orphans);
89
85
@@ -98,16 +94,16 @@ class TxOrphanage {
98
94
99
95
/* * Index from the parents' COutPoint into the m_orphans. Used
100
96
* to remove orphan transactions from the m_orphans */
101
- std::map<COutPoint, std::set<OrphanMap::iterator, IteratorComparator>> m_outpoint_to_orphan_it GUARDED_BY (m_mutex) ;
97
+ std::map<COutPoint, std::set<OrphanMap::iterator, IteratorComparator>> m_outpoint_to_orphan_it;
102
98
103
99
/* * Orphan transactions in vector for quick random eviction */
104
- std::vector<OrphanMap::iterator> m_orphan_list GUARDED_BY (m_mutex) ;
100
+ std::vector<OrphanMap::iterator> m_orphan_list;
105
101
106
102
/* * Erase an orphan by wtxid */
107
- int EraseTxNoLock (const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex) ;
103
+ int EraseTxNoLock (const Wtxid& wtxid);
108
104
109
105
/* * Timestamp for the next scheduled sweep of expired orphans */
110
- NodeSeconds m_next_sweep GUARDED_BY (m_mutex) {0s};
106
+ NodeSeconds m_next_sweep{0s};
111
107
};
112
108
113
109
#endif // BITCOIN_TXORPHANAGE_H
0 commit comments