Check for correct genesis

At startup, check that the expected genesis is loaded. This should prevent
cases where accidentally a datadir from the wrong network is loaded
(testnet vs mainnet, e.g.).
This commit is contained in:
Pieter Wuille
2013-05-12 12:03:32 +02:00
committed by Warren Togami
parent f346774f5a
commit 9ee8ffcca7

View File

@@ -864,6 +864,11 @@ bool AppInit2(boost::thread_group& threadGroup)
break;
}
// If the loaded chain has a wrong genesis, bail out immediately
// (we're likely using a testnet datadir, or the other way around).
if (!mapBlockIndex.empty() && pindexGenesisBlock == NULL)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
// Initialize the block index (no-op if non-empty database was already loaded)
if (!InitBlockIndex()) {
strLoadError = _("Error initializing block database");