From 303be2e442744593d8211b520f9fe554b3bd31a2 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Wed, 21 Jul 2021 22:29:32 +0200 Subject: Reduce getheaders spam by serializing getheader requests per peer Introduces a counter for getheader requests that have been sent to a peer but are pending response, reducing the number of parallel requests a node pushes out to its peers when needing to sync large amounts of headers. All getheader requests are serialized during initial sync, except when a non-connecting header is received, allowing the node to resolve issues with peers sending faulty blocks using the DoS mechanism, and when we get an inv for a block that we do not know, because it's possible we're only connected to legacy nodes that do not implement header announcement properly. --- src/net.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index e89f1b11d..2117c59fd 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2704,6 +2704,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn fPauseRecv = false; fPauseSend = false; nProcessQueueSize = 0; + nPendingHeaderRequests = 0; BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes()) mapRecvBytesPerMsgCmd[msg] = 0; -- cgit v1.2.3