Mercurial > hg > bitcoin
changeset 3163:7ce3f0954271 draft
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.
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Wed, 27 Jun 2012 13:51:51 -0400 |
parents | 1f4365b4bcd2 |
children | efc3e6428a8a c8919cc94799 |
files | src/main.cpp |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp +++ b/src/main.cpp @@ -1623,6 +1623,24 @@ 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())