Skip to content

Commit a8b936d

Browse files
committed
Use exposed ProcessNewBlockHeaders from ProcessMessages
1 parent 63fd101 commit a8b936d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/main.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6019,22 +6019,27 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
60196019
return true;
60206020
}
60216021

6022-
BOOST_FOREACH(const CBlockHeader& header, headers) {
6023-
CValidationState state;
6024-
if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) {
6022+
uint256 hashLastBlock;
6023+
for (const CBlockHeader& header : headers) {
6024+
if (!hashLastBlock.IsNull() && header.hashPrevBlock != hashLastBlock) {
60256025
Misbehaving(pfrom->GetId(), 20);
60266026
return error("non-continuous headers sequence");
60276027
}
6028-
if (!AcceptBlockHeader(header, state, chainparams, &pindexLast)) {
6029-
int nDoS;
6030-
if (state.IsInvalid(nDoS)) {
6031-
if (nDoS > 0)
6032-
Misbehaving(pfrom->GetId(), nDoS);
6033-
return error("invalid header received");
6028+
hashLastBlock = header.GetHash();
6029+
}
6030+
}
6031+
6032+
CValidationState state;
6033+
if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast)) {
6034+
int nDoS;
6035+
if (state.IsInvalid(nDoS)) {
6036+
if (nDoS > 0) {
6037+
LOCK(cs_main);
6038+
Misbehaving(pfrom->GetId(), nDoS);
60346039
}
6040+
return error("invalid header received");
60356041
}
60366042
}
6037-
}
60386043

60396044
{
60406045
LOCK(cs_main);
@@ -6110,8 +6115,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
61106115
}
61116116
}
61126117
}
6113-
6114-
NotifyHeaderTip();
61156118
}
61166119

61176120
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing

0 commit comments

Comments
 (0)