mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 07:09:29 +02:00
Cleanup received_new_header calculation to use WITH_LOCK
This commit is contained in:
@@ -2420,7 +2420,6 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool received_new_header = false;
|
|
||||||
const CBlockIndex *pindexLast = nullptr;
|
const CBlockIndex *pindexLast = nullptr;
|
||||||
|
|
||||||
// Do these headers connect to something in our block index?
|
// Do these headers connect to something in our block index?
|
||||||
@@ -2444,15 +2443,9 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// If we don't have the last header, then this peer will have given us
|
||||||
LOCK(cs_main);
|
// something new (if these headers are valid).
|
||||||
|
bool received_new_header{WITH_LOCK(::cs_main, return m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash()) == nullptr)};
|
||||||
// If we don't have the last header, then they'll have given us
|
|
||||||
// something new (if these headers are valid).
|
|
||||||
if (!m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash())) {
|
|
||||||
received_new_header = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!m_chainman.ProcessNewBlockHeaders(headers, state, &pindexLast)) {
|
if (!m_chainman.ProcessNewBlockHeaders(headers, state, &pindexLast)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user