Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,976 Lines • ▼ Show 20 Lines | static void ProcessGetData(const Config &config, CNode &pfrom, | ||||
const std::atomic<bool> &interruptMsgProc) | const std::atomic<bool> &interruptMsgProc) | ||||
LOCKS_EXCLUDED(cs_main) { | LOCKS_EXCLUDED(cs_main) { | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
std::deque<CInv>::iterator it = pfrom.vRecvGetData.begin(); | std::deque<CInv>::iterator it = pfrom.vRecvGetData.begin(); | ||||
std::vector<CInv> vNotFound; | std::vector<CInv> vNotFound; | ||||
const CNetMsgMaker msgMaker(pfrom.GetSendVersion()); | const CNetMsgMaker msgMaker(pfrom.GetSendVersion()); | ||||
// Note that if we receive a getdata for a MSG_TX from a block-relay-only | // mempool entries added before this time have likely expired from mapRelay | ||||
// outbound peer, we will stop processing further getdata messages from this | |||||
// peer (likely resulting in our peer eventually disconnecting us). | |||||
if (pfrom.m_tx_relay != nullptr) { | |||||
// mempool entries added before this time have likely expired from | |||||
// mapRelay | |||||
const std::chrono::seconds longlived_mempool_time = | const std::chrono::seconds longlived_mempool_time = | ||||
GetTime<std::chrono::seconds>() - RELAY_TX_CACHE_TIME; | GetTime<std::chrono::seconds>() - RELAY_TX_CACHE_TIME; | ||||
// Get last mempool request time | |||||
const std::chrono::seconds mempool_req = | const std::chrono::seconds mempool_req = | ||||
pfrom.m_tx_relay->m_last_mempool_req.load(); | pfrom.m_tx_relay != nullptr | ||||
? pfrom.m_tx_relay->m_last_mempool_req.load() | |||||
: std::chrono::seconds::min(); | |||||
{ | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
while (it != pfrom.vRecvGetData.end() && it->type == MSG_TX) { | while (it != pfrom.vRecvGetData.end() && it->type == MSG_TX) { | ||||
if (interruptMsgProc) { | if (interruptMsgProc) { | ||||
return; | return; | ||||
} | } | ||||
// 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) { | ||||
break; | break; | ||||
} | } | ||||
const CInv &inv = *it; | const CInv &inv = *it++; | ||||
it++; | |||||
if (pfrom.m_tx_relay == nullptr) { | |||||
// Ignore GETDATA requests for transactions from blocks-only | |||||
// peers. | |||||
continue; | |||||
} | |||||
// Send stream from relay memory | // Send stream from relay memory | ||||
bool push = false; | bool push = false; | ||||
auto mi = mapRelay.find(inv.hash); | auto mi = mapRelay.find(inv.hash); | ||||
int nSendFlags = 0; | int nSendFlags = 0; | ||||
if (mi != mapRelay.end()) { | if (mi != mapRelay.end()) { | ||||
connman.PushMessage( | connman.PushMessage( | ||||
&pfrom, | &pfrom, | ||||
▲ Show 20 Lines • Show All 3,487 Lines • Show Last 20 Lines |