Skip to content

Commit 8803aee

Browse files
committed
Move m_orphan_work_set to net_processing
1 parent 9c47cb2 commit 8803aee

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/net.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,6 @@ class CNode
10421042
// Whether a ping is requested.
10431043
std::atomic<bool> fPingQueued{false};
10441044

1045-
std::set<uint256> m_orphan_work_set;
1046-
10471045
CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion = false);
10481046
~CNode();
10491047
CNode(const CNode&) = delete;

src/net_processing.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ struct Peer {
512512
/** Whether this peer should be disconnected and marked as discouraged (unless it has the noban permission). */
513513
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false};
514514

515+
/** Set of txids to reconsider once their parent transactions have been accepted **/
516+
std::set<uint256> m_orphan_work_set;
517+
515518
Peer(NodeId id) : m_id(id) {}
516519
};
517520

@@ -2363,6 +2366,8 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
23632366
return;
23642367
}
23652368

2369+
PeerRef peer = GetPeerRef(pfrom.GetId());
2370+
if (peer == nullptr) return;
23662371

23672372
if (msg_type == NetMsgType::VERSION) {
23682373
// Each connection can only send one version message
@@ -3052,7 +3057,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
30523057
auto it_by_prev = mapOrphanTransactionsByPrev.find(COutPoint(txid, i));
30533058
if (it_by_prev != mapOrphanTransactionsByPrev.end()) {
30543059
for (const auto& elem : it_by_prev->second) {
3055-
pfrom.m_orphan_work_set.insert(elem->first);
3060+
peer->m_orphan_work_set.insert(elem->first);
30563061
}
30573062
}
30583063
}
@@ -3069,7 +3074,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
30693074
}
30703075

30713076
// Recursively process any orphan transactions that depended on this one
3072-
ProcessOrphanTx(pfrom.m_orphan_work_set);
3077+
ProcessOrphanTx(peer->m_orphan_work_set);
30733078
}
30743079
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
30753080
{
@@ -3865,12 +3870,15 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
38653870
{
38663871
bool fMoreWork = false;
38673872

3873+
PeerRef peer = GetPeerRef(pfrom->GetId());
3874+
if (peer == nullptr) return false;
3875+
38683876
if (!pfrom->vRecvGetData.empty())
38693877
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
38703878

3871-
if (!pfrom->m_orphan_work_set.empty()) {
3879+
if (!peer->m_orphan_work_set.empty()) {
38723880
LOCK2(cs_main, g_cs_orphans);
3873-
ProcessOrphanTx(pfrom->m_orphan_work_set);
3881+
ProcessOrphanTx(peer->m_orphan_work_set);
38743882
}
38753883

38763884
if (pfrom->fDisconnect)
@@ -3879,7 +3887,7 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
38793887
// this maintains the order of responses
38803888
// and prevents vRecvGetData to grow unbounded
38813889
if (!pfrom->vRecvGetData.empty()) return true;
3882-
if (!pfrom->m_orphan_work_set.empty()) return true;
3890+
if (!peer->m_orphan_work_set.empty()) return true;
38833891

38843892
// Don't bother if send buffer is too full to respond anyway
38853893
if (pfrom->fPauseSend)

0 commit comments

Comments
 (0)