Skip to content

Commit

Permalink
validation: Remove redundant request sync from ProcessNewBlock().
Browse files Browse the repository at this point in the history
ProcessNewBlock is called by ProcessMessage (NetMsgType::BLOCK command) which is doing the exact same check: if the node does not have the previous block, request sync up to it.

Github-Pull: #2295
Rebased-From: 959936f
  • Loading branch information
furszy committed Apr 9, 2021
1 parent c44b431 commit 64bd400
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3273,16 +3273,6 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const std::shared_pt
return error ("%s : CheckBlock FAILED for block %s, %s", __func__, pblock->GetHash().GetHex(), FormatStateMessage(state));
}

// Request sync if needed
if (pblock->GetHash() != consensus.hashGenesisBlock && !pfrom) {
// if we get this far, check if the prev block is our prev block, if not then request sync and return false
BlockMap::iterator mi = mapBlockIndex.find(pblock->hashPrevBlock);
if (mi == mapBlockIndex.end()) {
g_connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::GETBLOCKS, chainActive.GetLocator(), UINT256_ZERO));
return false;
}
}

// Store to disk
CBlockIndex* pindex = nullptr;
bool ret = AcceptBlock(*pblock, state, &pindex, dbp);
Expand Down

0 comments on commit 64bd400

Please sign in to comment.