aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-05-12 12:03:32 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2013-05-12 13:21:03 +0200
commit5d274c9927f01c590f187bbbc670a92e441c53b7 (patch)
tree1699afad77f03e2889988ec3a6bef9a8598fefa1 /src/init.cpp
parent5b5d399593adbdf8b9b4fb49ef39d51d4eac03cd (diff)
downloadbitcoin-5d274c9927f01c590f187bbbc670a92e441c53b7.tar.xz
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.).
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index d619cb4121..1e2ffe48e2 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -862,6 +862,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");