Browse Source

Warn if blockchain majority doesn't match CBlock::CURRENT_VERSION

This adds a warning "this version is obsolete, upgrade required" if
more than 50 of the previous 100 blocks in the blockchain are
a new version.
pull/145/head
Gavin Andresen 12 years ago
parent
commit
2a919e396d
  1. 18
      src/main.cpp

18
src/main.cpp

@ -1623,6 +1623,24 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(),
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str());
// Check the version of the last 100 blocks to see if we need to upgrade:
if (!fIsInitialDownload)
{
int nUpgraded = 0;
const CBlockIndex* pindex = pindexBest;
for (int i = 0; i < 100 && pindex != NULL; i++)
{
if (pindex->nVersion > CBlock::CURRENT_VERSION)
++nUpgraded;
pindex = pindex->pprev;
}
if (nUpgraded > 0)
printf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, CBlock::CURRENT_VERSION);
if (nUpgraded > 100/2)
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
strMiscWarning = _("Warning: this version is obsolete, upgrade required");
}
std::string strCmd = GetArg("-blocknotify", "");
if (!fIsInitialDownload && !strCmd.empty())

Loading…
Cancel
Save