Skip to content

Commit

Permalink
Don't revert to INV based block announcements when the previous block…
Browse files Browse the repository at this point in the history
… is the devnet genesis block (#2388)

Assume that the other node already has the previous block if it matches
the devnet genesis block.
  • Loading branch information
codablock authored and UdjinM6 committed Oct 26, 2018
1 parent b5142ee commit e66c4e1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3229,12 +3229,21 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
break;
}
pBestIndex = pindex;
bool isPrevDevnetGenesisBlock = false;
if (!consensusParams.hashDevnetGenesisBlock.IsNull() &&
pindex->pprev != nullptr &&
pindex->pprev->GetBlockHash() == consensusParams.hashDevnetGenesisBlock) {
// even though the devnet genesis block was never transferred through the wire and thus not
// appear anywhere in the node state where we track what other nodes have or not have, we can
// assume that the other node already knows the devnet genesis block
isPrevDevnetGenesisBlock = true;
}
if (fFoundStartingHeader) {
// add this to the headers message
vHeaders.push_back(pindex->GetBlockHeader());
} else if (PeerHasHeader(&state, pindex)) {
continue; // keep looking for the first new block
} else if (pindex->pprev == NULL || PeerHasHeader(&state, pindex->pprev)) {
} else if (pindex->pprev == NULL || PeerHasHeader(&state, pindex->pprev) || isPrevDevnetGenesisBlock) {
// Peer doesn't have this header but they do have the prior one.
// Start sending headers.
fFoundStartingHeader = true;
Expand Down

0 comments on commit e66c4e1

Please sign in to comment.