ProcessBlockAvailability revert to chain work

This commit is contained in:
jl777
2018-11-24 04:36:03 -11:00
parent 1334205235
commit 7d52a3c43a

View File

@@ -408,7 +408,7 @@ namespace {
CNodeState *state = State(nodeid); CNodeState *state = State(nodeid);
assert(state != NULL); assert(state != NULL);
if (!state->hashLastUnknownBlock.IsNull()) { /*if (!state->hashLastUnknownBlock.IsNull()) {
BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock);
if (itOld != mapBlockIndex.end() && itOld->second != 0 && (itOld->second->chainPower > CChainPower())) if (itOld != mapBlockIndex.end() && itOld->second != 0 && (itOld->second->chainPower > CChainPower()))
{ {
@@ -416,7 +416,17 @@ namespace {
state->pindexBestKnownBlock = itOld->second; state->pindexBestKnownBlock = itOld->second;
state->hashLastUnknownBlock.SetNull(); 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. */ /** 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; return true;
} }
fprintf(stderr,"netmsg: %s\n", strCommand.c_str()); //fprintf(stderr,"netmsg: %s\n", strCommand.c_str());
if (strCommand == "version") if (strCommand == "version")
{ {
@@ -6887,7 +6897,7 @@ fprintf(stderr,"netmsg: %s\n", strCommand.c_str());
if (chainActive.LastTip() != 0 && chainActive.LastTip()->GetHeight() > 100000 && IsInitialBlockDownload()) 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; return true;
} }
CBlockIndex* pindex = NULL; CBlockIndex* pindex = NULL;