From 7f1cf440ca1a9c86085716745ca64d3ac26957c0 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 23 Aug 2022 17:57:42 -0400 Subject: [PATCH] Simplify TryLowWorkHeadersSync invocation Make use of the fact that now TryLowWorkHeadersSync is (like IsContinuationOfLowWorkHeadersSync) an operation that partially processes headers, so it can be invoked in a similar way, only bailing out when there is nothing left to do. --- src/net_processing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 137ada81f32..774ef2855c5 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2807,14 +2807,14 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer, // At this point, the headers connect to something in our block index. // Do anti-DoS checks to determine if we should process or store for later // processing. - if (!already_validated_work && TryLowWorkHeadersSync(peer, pfrom, - chain_start_header, headers)) { - // If we successfully started a low-work headers sync, then there - // should be no headers to process any further. - Assume(headers.empty()); - return; + if (!already_validated_work) { + already_validated_work = TryLowWorkHeadersSync(peer, pfrom, chain_start_header, headers); + have_headers_sync = already_validated_work; } + // If there is nothing left to process, stop. + if (headers.empty()) return; + // At this point, we have a set of headers with sufficient work on them // which can be processed.