Don't revert to INV based block announcements when the previous block is the devnet genesis block (#2388)

Assume that the other node already has the previous block if it matches
the devnet genesis block.
This commit is contained in:
Alexander Block 2018-10-26 18:42:28 +02:00 committed by UdjinM6
parent b5142ee2ce
commit e66c4e184f

View File

@ -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;