aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2022-10-20 17:55:44 +0100
committerglozow <gloriajzhao@gmail.com>2022-10-24 15:41:35 +0100
commite23def8fcc4558b1a49ee8f2dd608fe91ced1d6d (patch)
tree3c48266a0f3f99c036cbe259e882ed94b50fc3e2 /src/net_processing.cpp
parentbb5bcf32baeb252d6f160f93b99d3e51715275c8 (diff)
[net processing] Handle IsContinuationOfLowWorkHeadersSync return value correctly when new headers sync is started
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 1c44ec9903..a6299be403 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2559,14 +2559,22 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
// Now a HeadersSyncState object for tracking this synchronization is created,
// process the headers using it as normal.
- return IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers);
+ if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers)) {
+ // Something went wrong, reset the headers sync.
+ peer.m_headers_sync.reset(nullptr);
+ LOCK(m_headers_presync_mutex);
+ m_headers_presync_stats.erase(peer.m_id);
+ }
} else {
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
- // Since this is a low-work headers chain, no further processing is required.
- headers = {};
- return true;
}
+
+ // The peer has not yet given us a chain that meets our work threshold,
+ // so we want to prevent further processing of the headers in any case.
+ headers = {};
+ return true;
}
+
return false;
}