diff options
author | Matt Corallo <git@bluematt.me> | 2016-11-03 16:56:33 -0400 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2016-12-01 11:03:31 -0800 |
commit | a8b936df2053e68208d106cddec06227ef563e41 (patch) | |
tree | 3fd8983ba0edaf814e23752fa4d737f966401802 | |
parent | 63fd101c529cf6e2bc5ecab244fd56e2c5be521f (diff) |
Use exposed ProcessNewBlockHeaders from ProcessMessages
-rw-r--r-- | src/main.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4cd5bebb7c..f88efe7b50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6019,22 +6019,27 @@ 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); @@ -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 |