Use exposed ProcessNewBlockHeaders from ProcessMessages
This commit is contained in:
parent
63fd101c52
commit
a8b936df20
1 changed files with 16 additions and 13 deletions
29
src/main.cpp
29
src/main.cpp
|
@ -6019,23 +6019,28 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||
return true;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const CBlockHeader& header, headers) {
|
||||
CValidationState state;
|
||||
if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) {
|
||||
uint256 hashLastBlock;
|
||||
for (const CBlockHeader& header : headers) {
|
||||
if (!hashLastBlock.IsNull() && header.hashPrevBlock != hashLastBlock) {
|
||||
Misbehaving(pfrom->GetId(), 20);
|
||||
return error("non-continuous headers sequence");
|
||||
}
|
||||
if (!AcceptBlockHeader(header, state, chainparams, &pindexLast)) {
|
||||
int nDoS;
|
||||
if (state.IsInvalid(nDoS)) {
|
||||
if (nDoS > 0)
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
return error("invalid header received");
|
||||
}
|
||||
}
|
||||
hashLastBlock = header.GetHash();
|
||||
}
|
||||
}
|
||||
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast)) {
|
||||
int nDoS;
|
||||
if (state.IsInvalid(nDoS)) {
|
||||
if (nDoS > 0) {
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
}
|
||||
return error("invalid header received");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
CNodeState *nodestate = State(pfrom->GetId());
|
||||
|
@ -6110,8 +6115,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotifyHeaderTip();
|
||||
}
|
||||
|
||||
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing
|
||||
|
|
Loading…
Reference in a new issue