Skip to content

Commit 21646d8

Browse files
committed
net_processing: missing cs_main lock for chainActive.GetLocator() call
1 parent 959936f commit 21646d8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,16 +1599,17 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
15991599
CInv inv(MSG_BLOCK, hashBlock);
16001600
LogPrint(BCLog::NET, "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
16011601

1602-
//sometimes we will be sent their most recent block and its not the one we want, in that case tell where we are
1602+
// sometimes we will be sent their most recent block and its not the one we want, in that case tell where we are
16031603
if (!mapBlockIndex.count(pblock->hashPrevBlock)) {
1604+
CBlockLocator locator = WITH_LOCK(cs_main, return chainActive.GetLocator(););
16041605
if (find(pfrom->vBlockRequested.begin(), pfrom->vBlockRequested.end(), hashBlock) != pfrom->vBlockRequested.end()) {
1605-
//we already asked for this block, so lets work backwards and ask for the previous block
1606-
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, chainActive.GetLocator(), pblock->hashPrevBlock));
1607-
pfrom->vBlockRequested.push_back(pblock->hashPrevBlock);
1606+
// we already asked for this block, so lets work backwards and ask for the previous block
1607+
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, locator, pblock->hashPrevBlock));
1608+
pfrom->vBlockRequested.emplace_back(pblock->hashPrevBlock);
16081609
} else {
1609-
//ask to sync to this block
1610-
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, chainActive.GetLocator(), hashBlock));
1611-
pfrom->vBlockRequested.push_back(hashBlock);
1610+
// ask to sync to this block
1611+
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, locator, hashBlock));
1612+
pfrom->vBlockRequested.emplace_back(hashBlock);
16121613
}
16131614
} else {
16141615
pfrom->AddInventoryKnown(inv);

0 commit comments

Comments
 (0)