Skip to content

Commit a3fe458

Browse files
jnewberyfanquake
authored andcommitted
[docs] Improve commenting in ProcessGetData()
Github-Pull: #18808 Rebased-From: 9847e20
1 parent 011532e commit a3fe458

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,10 +1573,14 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
15731573
{
15741574
LOCK(cs_main);
15751575

1576+
// Process as many TX items from the front of the getdata queue as
1577+
// possible, since they're common and it's efficient to batch process
1578+
// them.
15761579
while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) {
15771580
if (interruptMsgProc)
15781581
return;
1579-
// Don't bother if send buffer is too full to respond anyway
1582+
// The send buffer provides backpressure. If there's no space in
1583+
// the buffer, pause processing until the next call.
15801584
if (pfrom->fPauseSend)
15811585
break;
15821586

@@ -1613,6 +1617,8 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
16131617
}
16141618
} // release cs_main
16151619

1620+
// Only process one BLOCK item per call, since they're uncommon and can be
1621+
// expensive to process.
16161622
if (it != pfrom->vRecvGetData.end() && !pfrom->fPauseSend) {
16171623
const CInv &inv = *it++;
16181624
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK) {

0 commit comments

Comments
 (0)