Skip to content

Commit 58a215c

Browse files
committed
Use ProcessNewBlockHeaders in CMPCTBLOCK processing
1 parent a8b936d commit 58a215c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5768,6 +5768,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
57685768
CBlockHeaderAndShortTxIDs cmpctblock;
57695769
vRecv >> cmpctblock;
57705770

5771+
{
57715772
LOCK(cs_main);
57725773

57735774
if (mapBlockIndex.find(cmpctblock.header.hashPrevBlock) == mapBlockIndex.end()) {
@@ -5776,19 +5777,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
57765777
connman.PushMessage(pfrom, NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), uint256());
57775778
return true;
57785779
}
5780+
}
57795781

57805782
CBlockIndex *pindex = NULL;
57815783
CValidationState state;
5782-
if (!AcceptBlockHeader(cmpctblock.header, state, chainparams, &pindex)) {
5784+
if (!ProcessNewBlockHeaders({cmpctblock.header}, state, chainparams, &pindex)) {
57835785
int nDoS;
57845786
if (state.IsInvalid(nDoS)) {
5785-
if (nDoS > 0)
5787+
if (nDoS > 0) {
5788+
LOCK(cs_main);
57865789
Misbehaving(pfrom->GetId(), nDoS);
5790+
}
57875791
LogPrintf("Peer %d sent us invalid header via cmpctblock\n", pfrom->id);
57885792
return true;
57895793
}
57905794
}
57915795

5796+
LOCK(cs_main);
57925797
// If AcceptBlockHeader returned true, it set pindex
57935798
assert(pindex);
57945799
UpdateBlockAvailability(pfrom->GetId(), pindex->GetBlockHash());

0 commit comments

Comments
 (0)