aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-04-17 23:03:24 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-04-26 00:31:54 +0200
commit83743ed6810cfe6a0c0c260fa2477dffbe05950c (patch)
tree2b151b9c1453fcdd0da74deb9431ec2db29e15a7 /src/db.cpp
parentc2e8c8acd8ae0c94c70b59f55169841ad195bb99 (diff)
Make lsn_reset ("detach databases") optional and off by default.
Add an option -detachdb (and entry in OptionDialog), without which no lsn_reset is called on addr.dat and blkindex.dat. That means these files cannot be moved to a new environment, but shutdown can be significantly faster. The wallet file is always lsn_reset'ed. -detachdb corresponds to the old behaviour, though it is off by default now to speed up shutdowns.
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 53da378fee..12647e568a 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -28,6 +28,7 @@ unsigned int nWalletDBUpdated;
CCriticalSection cs_db;
static bool fDbEnvInit = false;
+bool fDetachDB = false;
DbEnv dbenv(0);
map<string, int> mapFileUseCount;
static map<string, Db*> mapDb;
@@ -307,9 +308,13 @@ void DBFlush(bool fShutdown)
{
// Move log data to the dat file
CloseDb(strFile);
+ printf("%s checkpoint\n", strFile.c_str());
dbenv.txn_checkpoint(0, 0, 0);
- printf("%s flush\n", strFile.c_str());
- dbenv.lsn_reset(strFile.c_str(), 0);
+ if ((strFile != "blkindex.dat" && strFile != "addr.dat") || fDetachDB) {
+ printf("%s detach\n", strFile.c_str());
+ dbenv.lsn_reset(strFile.c_str(), 0);
+ }
+ printf("%s closed\n", strFile.c_str());
mapFileUseCount.erase(mi++);
}
else