diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-11-11 03:16:52 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-11-11 03:16:52 -0800 |
commit | 537c890f24a56ff1fc4a95999477cf974f5f3882 (patch) | |
tree | 36ce5c9faf2f2f220bf005e93dbfb6994be3d5d4 /src/db.cpp | |
parent | 337f876cbbf4985d52a98ca1c349431de66e91ab (diff) | |
parent | c74bae0fdf211551e5a45d1b6bbc766d91381ad9 (diff) |
Merge pull request #1997 from Diapolo/bdb_open
simplify CDBEnv::Open() / fix small glitches
Diffstat (limited to 'src/db.cpp')
-rw-r--r-- | src/db.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/db.cpp b/src/db.cpp index fb405fc277..60e1f6f280 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -55,7 +55,7 @@ void CDBEnv::Close() EnvShutdown(); } -bool CDBEnv::Open(boost::filesystem::path pathEnv_) +bool CDBEnv::Open(const boost::filesystem::path& path) { if (fDbEnvInit) return true; @@ -63,18 +63,16 @@ bool CDBEnv::Open(boost::filesystem::path pathEnv_) if (fShutdown) return false; - pathEnv = pathEnv_; - filesystem::path pathDataDir = pathEnv; - filesystem::path pathLogDir = pathDataDir / "database"; + filesystem::path pathLogDir = path / "database"; filesystem::create_directory(pathLogDir); - filesystem::path pathErrorFile = pathDataDir / "db.log"; + filesystem::path pathErrorFile = path / "db.log"; printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str()); unsigned int nEnvFlags = 0; if (GetBoolArg("-privdb", true)) nEnvFlags |= DB_PRIVATE; - int nDbCache = GetArg("-dbcache", 25); + unsigned int nDbCache = GetArg("-dbcache", 25); dbenv.set_lg_dir(pathLogDir.string().c_str()); dbenv.set_cachesize(nDbCache / 1024, (nDbCache % 1024)*1048576, 1); dbenv.set_lg_bsize(1048576); @@ -85,7 +83,7 @@ bool CDBEnv::Open(boost::filesystem::path pathEnv_) dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); - int ret = dbenv.open(pathDataDir.string().c_str(), + int ret = dbenv.open(path.string().c_str(), DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | |