@@ -22,7 +22,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
22
22
AssertLockHeld (g_cs_orphans);
23
23
24
24
const uint256& hash = tx->GetHash ();
25
- if (mapOrphanTransactions .count (hash))
25
+ if (m_orphans .count (hash))
26
26
return false ;
27
27
28
28
// Ignore big transactions, to avoid a
@@ -39,49 +39,49 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
39
39
return false ;
40
40
}
41
41
42
- auto ret = mapOrphanTransactions .emplace (hash, COrphanTx {tx, peer, GetTime () + ORPHAN_TX_EXPIRE_TIME, g_orphan_list .size ()});
42
+ auto ret = m_orphans .emplace (hash, OrphanTx {tx, peer, GetTime () + ORPHAN_TX_EXPIRE_TIME, m_orphan_list .size ()});
43
43
assert (ret.second );
44
- g_orphan_list .push_back (ret.first );
44
+ m_orphan_list .push_back (ret.first );
45
45
// Allow for lookups in the orphan pool by wtxid, as well as txid
46
- g_orphans_by_wtxid .emplace (tx->GetWitnessHash (), ret.first );
46
+ m_wtxid_to_orphan_it .emplace (tx->GetWitnessHash (), ret.first );
47
47
for (const CTxIn& txin : tx->vin ) {
48
- mapOrphanTransactionsByPrev [txin.prevout ].insert (ret.first );
48
+ m_outpoint_to_orphan_it [txin.prevout ].insert (ret.first );
49
49
}
50
50
51
51
LogPrint (BCLog::MEMPOOL, " stored orphan tx %s (mapsz %u outsz %u)\n " , hash.ToString (),
52
- mapOrphanTransactions .size (), mapOrphanTransactionsByPrev .size ());
52
+ m_orphans .size (), m_outpoint_to_orphan_it .size ());
53
53
return true ;
54
54
}
55
55
56
56
int TxOrphanage::EraseTx (const uint256& txid)
57
57
{
58
58
AssertLockHeld (g_cs_orphans);
59
- std::map<uint256, COrphanTx >::iterator it = mapOrphanTransactions .find (txid);
60
- if (it == mapOrphanTransactions .end ())
59
+ std::map<uint256, OrphanTx >::iterator it = m_orphans .find (txid);
60
+ if (it == m_orphans .end ())
61
61
return 0 ;
62
62
for (const CTxIn& txin : it->second .tx ->vin )
63
63
{
64
- auto itPrev = mapOrphanTransactionsByPrev .find (txin.prevout );
65
- if (itPrev == mapOrphanTransactionsByPrev .end ())
64
+ auto itPrev = m_outpoint_to_orphan_it .find (txin.prevout );
65
+ if (itPrev == m_outpoint_to_orphan_it .end ())
66
66
continue ;
67
67
itPrev->second .erase (it);
68
68
if (itPrev->second .empty ())
69
- mapOrphanTransactionsByPrev .erase (itPrev);
69
+ m_outpoint_to_orphan_it .erase (itPrev);
70
70
}
71
71
72
72
size_t old_pos = it->second .list_pos ;
73
- assert (g_orphan_list [old_pos] == it);
74
- if (old_pos + 1 != g_orphan_list .size ()) {
75
- // Unless we're deleting the last entry in g_orphan_list , move the last
73
+ assert (m_orphan_list [old_pos] == it);
74
+ if (old_pos + 1 != m_orphan_list .size ()) {
75
+ // Unless we're deleting the last entry in m_orphan_list , move the last
76
76
// entry to the position we're deleting.
77
- auto it_last = g_orphan_list .back ();
78
- g_orphan_list [old_pos] = it_last;
77
+ auto it_last = m_orphan_list .back ();
78
+ m_orphan_list [old_pos] = it_last;
79
79
it_last->second .list_pos = old_pos;
80
80
}
81
- g_orphan_list .pop_back ();
82
- g_orphans_by_wtxid .erase (it->second .tx ->GetWitnessHash ());
81
+ m_orphan_list .pop_back ();
82
+ m_wtxid_to_orphan_it .erase (it->second .tx ->GetWitnessHash ());
83
83
84
- mapOrphanTransactions .erase (it);
84
+ m_orphans .erase (it);
85
85
return 1 ;
86
86
}
87
87
@@ -90,10 +90,10 @@ void TxOrphanage::EraseForPeer(NodeId peer)
90
90
AssertLockHeld (g_cs_orphans);
91
91
92
92
int nErased = 0 ;
93
- std::map<uint256, COrphanTx >::iterator iter = mapOrphanTransactions .begin ();
94
- while (iter != mapOrphanTransactions .end ())
93
+ std::map<uint256, OrphanTx >::iterator iter = m_orphans .begin ();
94
+ while (iter != m_orphans .end ())
95
95
{
96
- std::map<uint256, COrphanTx >::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
96
+ std::map<uint256, OrphanTx >::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
97
97
if (maybeErase->second .fromPeer == peer)
98
98
{
99
99
nErased += EraseTx (maybeErase->second .tx ->GetHash ());
@@ -102,7 +102,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
102
102
if (nErased > 0 ) LogPrint (BCLog::MEMPOOL, " Erased %d orphan tx from peer=%d\n " , nErased, peer);
103
103
}
104
104
105
- unsigned int TxOrphanage::LimitOrphans (unsigned int nMaxOrphans )
105
+ unsigned int TxOrphanage::LimitOrphans (unsigned int max_orphans )
106
106
{
107
107
AssertLockHeld (g_cs_orphans);
108
108
@@ -113,10 +113,10 @@ unsigned int TxOrphanage::LimitOrphans(unsigned int nMaxOrphans)
113
113
// Sweep out expired orphan pool entries:
114
114
int nErased = 0 ;
115
115
int64_t nMinExpTime = nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL;
116
- std::map<uint256, COrphanTx >::iterator iter = mapOrphanTransactions .begin ();
117
- while (iter != mapOrphanTransactions .end ())
116
+ std::map<uint256, OrphanTx >::iterator iter = m_orphans .begin ();
117
+ while (iter != m_orphans .end ())
118
118
{
119
- std::map<uint256, COrphanTx >::iterator maybeErase = iter++;
119
+ std::map<uint256, OrphanTx >::iterator maybeErase = iter++;
120
120
if (maybeErase->second .nTimeExpire <= nNow) {
121
121
nErased += EraseTx (maybeErase->second .tx ->GetHash ());
122
122
} else {
@@ -128,11 +128,11 @@ unsigned int TxOrphanage::LimitOrphans(unsigned int nMaxOrphans)
128
128
if (nErased > 0 ) LogPrint (BCLog::MEMPOOL, " Erased %d orphan tx due to expiration\n " , nErased);
129
129
}
130
130
FastRandomContext rng;
131
- while (mapOrphanTransactions .size () > nMaxOrphans )
131
+ while (m_orphans .size () > max_orphans )
132
132
{
133
133
// Evict a random orphan:
134
- size_t randompos = rng.randrange (g_orphan_list .size ());
135
- EraseTx (g_orphan_list [randompos]->first );
134
+ size_t randompos = rng.randrange (m_orphan_list .size ());
135
+ EraseTx (m_orphan_list [randompos]->first );
136
136
++nEvicted;
137
137
}
138
138
return nEvicted;
@@ -142,8 +142,8 @@ void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx, std::set<uint256>
142
142
{
143
143
AssertLockHeld (g_cs_orphans);
144
144
for (unsigned int i = 0 ; i < tx.vout .size (); i++) {
145
- const auto it_by_prev = mapOrphanTransactionsByPrev .find (COutPoint (tx.GetHash (), i));
146
- if (it_by_prev != mapOrphanTransactionsByPrev .end ()) {
145
+ const auto it_by_prev = m_outpoint_to_orphan_it .find (COutPoint (tx.GetHash (), i));
146
+ if (it_by_prev != m_outpoint_to_orphan_it .end ()) {
147
147
for (const auto & elem : it_by_prev->second ) {
148
148
orphan_work_set.insert (elem->first );
149
149
}
@@ -155,18 +155,18 @@ bool TxOrphanage::HaveTx(const GenTxid& gtxid) const
155
155
{
156
156
LOCK (g_cs_orphans);
157
157
if (gtxid.IsWtxid ()) {
158
- return g_orphans_by_wtxid .count (gtxid.GetHash ());
158
+ return m_wtxid_to_orphan_it .count (gtxid.GetHash ());
159
159
} else {
160
- return mapOrphanTransactions .count (gtxid.GetHash ());
160
+ return m_orphans .count (gtxid.GetHash ());
161
161
}
162
162
}
163
163
164
164
std::pair<CTransactionRef, NodeId> TxOrphanage::GetTx (const uint256& txid) const
165
165
{
166
166
AssertLockHeld (g_cs_orphans);
167
167
168
- const auto it = mapOrphanTransactions .find (txid);
169
- if (it == mapOrphanTransactions .end ()) return {nullptr , -1 };
168
+ const auto it = m_orphans .find (txid);
169
+ if (it == m_orphans .end ()) return {nullptr , -1 };
170
170
return {it->second .tx , it->second .fromPeer };
171
171
}
172
172
@@ -181,8 +181,8 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
181
181
182
182
// Which orphan pool entries must we evict?
183
183
for (const auto & txin : tx.vin ) {
184
- auto itByPrev = mapOrphanTransactionsByPrev .find (txin.prevout );
185
- if (itByPrev == mapOrphanTransactionsByPrev .end ()) continue ;
184
+ auto itByPrev = m_outpoint_to_orphan_it .find (txin.prevout );
185
+ if (itByPrev == m_outpoint_to_orphan_it .end ()) continue ;
186
186
for (auto mi = itByPrev->second .begin (); mi != itByPrev->second .end (); ++mi) {
187
187
const CTransaction& orphanTx = *(*mi)->second .tx ;
188
188
const uint256& orphanHash = orphanTx.GetHash ();
0 commit comments