diff options
author | fanquake <fanquake@gmail.com> | 2022-10-31 15:28:43 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-10-31 15:35:21 +0000 |
commit | 43e813cab266eef42e622519836f171f6a18d426 (patch) | |
tree | 67ffed6b7e2f5b70916d8191426c29ed54d2abf2 | |
parent | 4766cd198172225c66a0adb01f6cb9513c3d0e66 (diff) | |
parent | 784b02319128988038d4bd82f05736be22f14ee9 (diff) | |
download | bitcoin-43e813cab266eef42e622519836f171f6a18d426.tar.xz |
Merge bitcoin/bitcoin#26387: p2p: TryLowWorkHeadersSync follow-ups
784b02319128988038d4bd82f05736be22f14ee9 [net processing] Simplify use of IsContinuationOfLowWorkHeadersSync in TryLowWorkHeaderSync (dergoegge)
e891aabf5a4992a65b9c5ae8606f8dd08515b310 [net processing] Fixup TryLowWorkHeadersSync comment (dergoegge)
Pull request description:
See https://github.com/bitcoin/bitcoin/pull/26355#discussion_r1003561481 and https://github.com/bitcoin/bitcoin/pull/26355#discussion_r1004554187
ACKs for top commit:
hernanmarino:
ACK 784b02319128988038d4bd82f05736be22f14ee9
brunoerg:
crACK 784b02319128988038d4bd82f05736be22f14ee9
mzumsande:
ACK 784b02319128988038d4bd82f05736be22f14ee9
Tree-SHA512: b47ac0d78a09ca3a1806e38c5d2e2fcf1e5f0668f202450b5079c5cb168e168ac6828c0948d23f3610696375134986d75ef3c6098858173023bcb743aec8004c
-rw-r--r-- | src/net_processing.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index e2d70fc2c8..6c310b3fcd 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -638,9 +638,8 @@ private: * @param[in] chain_start_header Where these headers connect in our index. * @param[in,out] headers The headers to be processed. * - * @return True if chain was low work and a headers sync was - * initiated (and headers will be empty after calling); false - * otherwise. + * @return True if chain was low work (headers will be empty after + * calling); false otherwise. */ bool TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlockIndex* chain_start_header, @@ -2563,14 +2562,10 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(), chain_start_header, minimum_chain_work)); - // Now a HeadersSyncState object for tracking this synchronization is created, - // process the headers using it as normal. - 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); - } + // Now a HeadersSyncState object for tracking this synchronization + // is created, process the headers using it as normal. Failures are + // handled inside of IsContinuationOfLowWorkHeadersSync. + (void)IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers); } else { LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId()); } |