diff --git a/src/main.cpp b/src/main.cpp index 00a2412f5..1d1bac599 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -408,7 +408,7 @@ namespace { CNodeState *state = State(nodeid); assert(state != NULL); - if (!state->hashLastUnknownBlock.IsNull()) { + /*if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); if (itOld != mapBlockIndex.end() && itOld->second != 0 && (itOld->second->chainPower > CChainPower())) { @@ -416,7 +416,17 @@ namespace { state->pindexBestKnownBlock = itOld->second; state->hashLastUnknownBlock.SetNull(); } + }*/ + if (!state->hashLastUnknownBlock.IsNull()) { + BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); + if (itOld != mapBlockIndex.end() && itOld->second != 0 && (itOld->second->nChainWork > 0)) + { + if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) + state->pindexBestKnownBlock = itOld->second; + state->hashLastUnknownBlock.SetNull(); + } } + } /** Update tracking information about which blocks a peer is assumed to have. */ @@ -6510,7 +6520,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } -fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); +//fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (strCommand == "version") { @@ -6887,7 +6897,7 @@ fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); if (chainActive.LastTip() != 0 && chainActive.LastTip()->GetHeight() > 100000 && IsInitialBlockDownload()) { - fprintf(stderr,"dont process getheaders during initial download\n"); + //fprintf(stderr,"dont process getheaders during initial download\n"); return true; } CBlockIndex* pindex = NULL;