diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2012-06-27 13:51:51 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2012-07-06 11:37:01 -0400 |
commit | 2a919e396d95425fd2a3411c1716b7ccfe719540 (patch) | |
tree | cdb1f7b2cfdae4fe17e687e2e05020e7485eade4 /src/main.cpp | |
parent | dae3e10a5abe93833c57183b7c00f1db9200f46e (diff) |
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.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 499f4e336a..3052cfb8c4 100644 --- a/src/main.cpp +++ b/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()) |