Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 605 Lines • ▼ Show 20 Lines | struct Peer { | ||||
/** Whether this peer should be disconnected and marked as discouraged | /** Whether this peer should be disconnected and marked as discouraged | ||||
* (unless it has the noban permission). */ | * (unless it has the noban permission). */ | ||||
bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false}; | bool m_should_discourage GUARDED_BY(m_misbehavior_mutex){false}; | ||||
/** | /** | ||||
* Set of txids to reconsider once their parent transactions have been | * Set of txids to reconsider once their parent transactions have been | ||||
* accepted | * accepted | ||||
*/ | */ | ||||
std::set<TxId> m_orphan_work_set; | std::set<TxId> m_orphan_work_set GUARDED_BY(g_cs_orphans); | ||||
Peer(NodeId id) : m_id(id) {} | Peer(NodeId id) : m_id(id) {} | ||||
}; | }; | ||||
using PeerRef = std::shared_ptr<Peer>; | using PeerRef = std::shared_ptr<Peer>; | ||||
/** | /** | ||||
* Map of all Peer objects, keyed by peer id. This map is protected | * Map of all Peer objects, keyed by peer id. This map is protected | ||||
▲ Show 20 Lines • Show All 4,232 Lines • ▼ Show 20 Lines | bool PeerManager::ProcessMessages(const Config &config, CNode *pfrom, | ||||
if (peer == nullptr) { | if (peer == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!pfrom->vRecvGetData.empty()) { | if (!pfrom->vRecvGetData.empty()) { | ||||
ProcessGetData(config, *pfrom, m_connman, m_mempool, interruptMsgProc); | ProcessGetData(config, *pfrom, m_connman, m_mempool, interruptMsgProc); | ||||
} | } | ||||
if (!peer->m_orphan_work_set.empty()) { | { | ||||
LOCK2(cs_main, g_cs_orphans); | LOCK2(cs_main, g_cs_orphans); | ||||
if (!peer->m_orphan_work_set.empty()) { | |||||
ProcessOrphanTx(config, peer->m_orphan_work_set); | ProcessOrphanTx(config, peer->m_orphan_work_set); | ||||
} | } | ||||
} | |||||
if (pfrom->fDisconnect) { | if (pfrom->fDisconnect) { | ||||
return false; | return false; | ||||
} | } | ||||
// this maintains the order of responses and prevents vRecvGetData from | // this maintains the order of responses and prevents vRecvGetData from | ||||
// growing unbounded | // growing unbounded | ||||
if (!pfrom->vRecvGetData.empty()) { | if (!pfrom->vRecvGetData.empty()) { | ||||
return true; | return true; | ||||
} | } | ||||
{ | |||||
LOCK(g_cs_orphans); | |||||
if (!peer->m_orphan_work_set.empty()) { | if (!peer->m_orphan_work_set.empty()) { | ||||
return true; | return true; | ||||
} | } | ||||
} | |||||
// Don't bother if send buffer is too full to respond anyway | // Don't bother if send buffer is too full to respond anyway | ||||
if (pfrom->fPauseSend) { | if (pfrom->fPauseSend) { | ||||
return false; | return false; | ||||
} | } | ||||
std::list<CNetMessage> msgs; | std::list<CNetMessage> msgs; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,107 Lines • Show Last 20 Lines |