Skip to content

Commit

Permalink
Fix stuck initial sync
Browse files Browse the repository at this point in the history
  • Loading branch information
presstab committed Aug 15, 2016
1 parent 078617b commit 3bddcd3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 3bddcd3

Please sign in to comment.