Skip to content

Commit 9847e20

Browse files
committed
[docs] Improve commenting in ProcessGetData()
1 parent 2f03255 commit 9847e20

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
@@ -1604,10 +1604,14 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
16041604
{
16051605
LOCK(cs_main);
16061606

1607+
// Process as many TX items from the front of the getdata queue as
1608+
// possible, since they're common and it's efficient to batch process
1609+
// them.
16071610
while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) {
16081611
if (interruptMsgProc)
16091612
return;
1610-
// Don't bother if send buffer is too full to respond anyway
1613+
// The send buffer provides backpressure. If there's no space in
1614+
// the buffer, pause processing until the next call.
16111615
if (pfrom->fPauseSend)
16121616
break;
16131617

@@ -1644,6 +1648,8 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
16441648
}
16451649
} // release cs_main
16461650

1651+
// Only process one BLOCK item per call, since they're uncommon and can be
1652+
// expensive to process.
16471653
if (it != pfrom->vRecvGetData.end() && !pfrom->fPauseSend) {
16481654
const CInv &inv = *it++;
16491655
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)