P2P: Do not request blocks from peers with fewer blocks than us

If the remote node has a shorter chain, do not waste our
special getblocks request on them.
This commit is contained in:
Jeff Garzik 2012-09-24 13:26:09 -04:00 committed by Jeff Garzik
parent 6cbae37667
commit 93dd68e924
1 changed files with 1 additions and 0 deletions

View File

@ -2513,6 +2513,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Ask the first connected node for block updates
static int nAskedForBlocks = 0;
if (!pfrom->fClient && !pfrom->fOneShot &&
(pfrom->nStartingHeight > (nBestHeight - 144)) &&
(pfrom->nVersion < NOBLKS_VERSION_START ||
pfrom->nVersion >= NOBLKS_VERSION_END) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))