From 3bddcd357e3d7c3db8684123e0de103f5d1c502e Mon Sep 17 00:00:00 2001 From: presstab Date: Mon, 15 Aug 2016 15:21:38 -0600 Subject: [PATCH] Fix stuck initial sync --- src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5cdbc6f0947bb..86631881d1e92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5148,10 +5148,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, //sometimes we will be sent their most recent block and its not the one we want, in that case tell where we are if(!mapBlockIndex.count(block.hashPrevBlock) && (!pfrom->fAskedReorg || pfrom->fAbleToReorg)) { - //since our last block hash does not match, we will initiate reorg communications with this node - CBlockIndex* pindexMaxReorg = chainActive[chainActive.Tip()->nHeight - Params().MaxReorganizationDepth() + 1]; - pfrom->PushMessage("abletoreorg", pindexMaxReorg->GetBlockHash(), pindexMaxReorg->nHeight); - pfrom->fAskedReorg = true; + if(IsInitialBlockDownload()) + pfrom->PushMessage("getblocks", chainActive.GetLocator(), uint256(0)); + else + { + //since our last block hash does not match, we will initiate reorg communications with this node + CBlockIndex* pindexMaxReorg = chainActive[chainActive.Tip()->nHeight - Params().MaxReorganizationDepth() + 1]; + pfrom->PushMessage("abletoreorg", pindexMaxReorg->GetBlockHash(), pindexMaxReorg->nHeight); + pfrom->fAskedReorg = true; + } } else {