From 7d52a3c43a7c96af7aa8d67e662512084a637eba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Nov 2018 04:36:03 -1100 Subject: [PATCH] ProcessBlockAvailability revert to chain work --- src/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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;