aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-04-28 20:28:51 -0400
committerfanquake <fanquake@gmail.com>2020-05-15 07:42:07 +0800
commita3fe458a1e477cacd19e7e0edb8e7bb965067115 (patch)
tree1def3515e98d81ce26b92fad91f368563e8b2919 /src
parent011532e380bb1a42eac9e79a17b35531f768becf (diff)
[docs] Improve commenting in ProcessGetData()
Github-Pull: #18808 Rebased-From: 9847e205bf7edcac4c30ce4b6d62f482aa7bc1b7
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index a6f9445a9d..2db2619a81 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1573,10 +1573,14 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
{
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 || it->type == MSG_WITNESS_TX)) {
if (interruptMsgProc)
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)
break;
@@ -1613,6 +1617,8 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
}
} // 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) {
const CInv &inv = *it++;
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK || inv.type == MSG_CMPCT_BLOCK || inv.type == MSG_WITNESS_BLOCK) {