diff options
author | Matt Corallo <git@bluematt.me> | 2016-11-03 17:01:39 -0400 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2016-12-01 11:03:31 -0800 |
commit | 58a215ce8c13b900cf982c39f8ee4879290d1a95 (patch) | |
tree | a11879a1c67be6cc8238c4ff8a1f225c136dba9b /src/main.cpp | |
parent | a8b936df2053e68208d106cddec06227ef563e41 (diff) |
Use ProcessNewBlockHeaders in CMPCTBLOCK processing
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index f88efe7b50..04a55b3dcc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5768,6 +5768,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CBlockHeaderAndShortTxIDs cmpctblock; vRecv >> cmpctblock; + { LOCK(cs_main); if (mapBlockIndex.find(cmpctblock.header.hashPrevBlock) == mapBlockIndex.end()) { @@ -5776,19 +5777,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, connman.PushMessage(pfrom, NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), uint256()); return true; } + } CBlockIndex *pindex = NULL; CValidationState state; - if (!AcceptBlockHeader(cmpctblock.header, state, chainparams, &pindex)) { + if (!ProcessNewBlockHeaders({cmpctblock.header}, state, chainparams, &pindex)) { int nDoS; if (state.IsInvalid(nDoS)) { - if (nDoS > 0) + if (nDoS > 0) { + LOCK(cs_main); Misbehaving(pfrom->GetId(), nDoS); + } LogPrintf("Peer %d sent us invalid header via cmpctblock\n", pfrom->id); return true; } } + LOCK(cs_main); // If AcceptBlockHeader returned true, it set pindex assert(pindex); UpdateBlockAvailability(pfrom->GetId(), pindex->GetBlockHash()); |