Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,988 Lines • ▼ Show 20 Lines | static void ProcessGetData(const Config &config, CNode &pfrom, | ||||
const std::chrono::seconds mempool_req = | const std::chrono::seconds mempool_req = | ||||
pfrom.m_tx_relay != nullptr | pfrom.m_tx_relay != nullptr | ||||
? pfrom.m_tx_relay->m_last_mempool_req.load() | ? pfrom.m_tx_relay->m_last_mempool_req.load() | ||||
: std::chrono::seconds::min(); | : std::chrono::seconds::min(); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Process as many TX items from the front of the getdata queue as | |||||
// possible, since they're common and it's efficient to batch process | |||||
// them. | |||||
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. | // The send buffer provides backpressure. If there's no space in | ||||
// the buffer, pause processing until the next call. | |||||
if (pfrom.fPauseSend) { | if (pfrom.fPauseSend) { | ||||
break; | break; | ||||
} | } | ||||
const CInv &inv = *it++; | const CInv &inv = *it++; | ||||
if (pfrom.m_tx_relay == nullptr) { | if (pfrom.m_tx_relay == nullptr) { | ||||
// Ignore GETDATA requests for transactions from blocks-only | // Ignore GETDATA requests for transactions from blocks-only | ||||
Show All 32 Lines | const std::chrono::seconds mempool_req = | ||||
// unbroadcast set. | // unbroadcast set. | ||||
mempool.RemoveUnbroadcastTx(TxId(inv.hash)); | mempool.RemoveUnbroadcastTx(TxId(inv.hash)); | ||||
} else { | } else { | ||||
vNotFound.push_back(inv); | vNotFound.push_back(inv); | ||||
} | } | ||||
} | } | ||||
} // release cs_main | } // release cs_main | ||||
// Only process one BLOCK item per call, since they're uncommon and can be | |||||
// expensive to process. | |||||
if (it != pfrom.vRecvGetData.end() && !pfrom.fPauseSend) { | if (it != pfrom.vRecvGetData.end() && !pfrom.fPauseSend) { | ||||
const CInv &inv = *it++; | const CInv &inv = *it++; | ||||
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || | if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || | ||||
inv.type == MSG_CMPCT_BLOCK) { | inv.type == MSG_CMPCT_BLOCK) { | ||||
ProcessGetBlockData(config, pfrom, inv, connman, interruptMsgProc); | ProcessGetBlockData(config, pfrom, inv, connman, interruptMsgProc); | ||||
} | } | ||||
// else: If the first item on the queue is an unknown type, we erase it | // else: If the first item on the queue is an unknown type, we erase it | ||||
// and continue processing the queue on the next call. | // and continue processing the queue on the next call. | ||||
▲ Show 20 Lines • Show All 3,446 Lines • Show Last 20 Lines |