mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-13 11:25:02 -05:00
[net processing] Handle IsContinuationOfLowWorkHeadersSync return value correctly when new headers sync is started
This commit is contained in:
parent
fabc031048
commit
7ad15d1100
1 changed files with 12 additions and 4 deletions
|
@ -2565,14 +2565,22 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
|
||||||
|
|
||||||
// Now a HeadersSyncState object for tracking this synchronization is created,
|
// Now a HeadersSyncState object for tracking this synchronization is created,
|
||||||
// process the headers using it as normal.
|
// 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 {
|
} else {
|
||||||
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
|
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.
|
}
|
||||||
|
|
||||||
|
// 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 = {};
|
headers = {};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue