aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-10-08 17:18:17 -0400
committerGavin Andresen <gavinandresen@gmail.com>2012-10-08 17:18:17 -0400
commitc2bb42168ba19bb8be4d330238080cb4233cd390 (patch)
treea41c410e8fe04edd5e01d714979b1ef09b44cd42 /src/init.cpp
parent43de64949c96b6d708b7d8a82c3dba0f6ddf059e (diff)
parente4954b12971a3f9c0d9bddfbabbfba36d4e9a747 (diff)
Merge branch 'BDB_DOWNGRADE'
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 0084dd6744..d271893644 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -439,8 +439,9 @@ bool AppInit2()
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
if (file) fclose(file);
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
+ const char* pszDataDir = GetDataDir().string().c_str();
if (!lock.try_lock())
- return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().string().c_str()));
+ return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), pszDataDir));
#if !defined(WIN32) && !defined(QT_GUI)
if (fDaemon)
@@ -472,7 +473,7 @@ bool AppInit2()
if (!fLogTimestamps)
printf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
- printf("Used data directory %s\n", GetDataDir().string().c_str());
+ printf("Used data directory %s\n", pszDataDir);
std::ostringstream strErrors;
if (fDaemon)
@@ -588,6 +589,14 @@ bool AppInit2()
// ********************************************************* Step 6: load blockchain
+ if (!bitdb.Open(GetDataDir()))
+ {
+ string msg = strprintf(_("Error initializing database environment %s!"
+ " To recover, BACKUP THAT DIRECTORY, then remove"
+ " everything from it except for wallet.dat."), pszDataDir);
+ return InitError(msg);
+ }
+
if (GetBoolArg("-loadblockindextest"))
{
CTxDB txdb("r");
@@ -600,7 +609,7 @@ bool AppInit2()
printf("Loading block index...\n");
nStart = GetTimeMillis();
if (!LoadBlockIndex())
- strErrors << _("Error loading blkindex.dat") << "\n";
+ return InitError(_("Error loading blkindex.dat"));
// as LoadBlockIndex can take several minutes, it's possible the user
// requested to kill bitcoin-qt during the last operation. If so, exit.