From 4ac57f013e20da2d0f87fff69625cbd4419089f3 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Sun, 1 Nov 2009 01:16:51 +0000 Subject: move debug.log and db.log to data dir, portable GetDataDir, optimize GetBalance, fix repaint bogdown, -addnode and -? switches git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@25 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- db.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'db.cpp') diff --git a/db.cpp b/db.cpp index 699a94f2ea..f9e25834d0 100644 --- a/db.cpp +++ b/db.cpp @@ -61,18 +61,19 @@ CDB::CDB(const char* pszFile, const char* pszMode, bool fTxn) : pdb(NULL) { if (fShutdown) return; - string strAppDir = GetAppDir(); - string strLogDir = strAppDir + "\\database"; + string strDataDir = GetDataDir(); + string strLogDir = strDataDir + "\\database"; _mkdir(strLogDir.c_str()); - printf("dbenv.open strAppDir=%s\n", strAppDir.c_str()); + string strErrorFile = strDataDir + "\\db.log"; + printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str()); dbenv.set_lg_dir(strLogDir.c_str()); dbenv.set_lg_max(10000000); dbenv.set_lk_max_locks(10000); dbenv.set_lk_max_objects(10000); - dbenv.set_errfile(fopen("db.log", "a")); /// debug + dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug ///dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); /// causes corruption - ret = dbenv.open(strAppDir.c_str(), + ret = dbenv.open(strDataDir.c_str(), DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | @@ -139,6 +140,8 @@ void DBFlush(bool fShutdown) // Flush log data to the actual data file // on all files that are not in use printf("DBFlush(%s)\n", fShutdown ? "true" : "false"); + if (!fDbEnvInit) + return; CRITICAL_BLOCK(cs_db) { dbenv.txn_checkpoint(0, 0, 0); @@ -421,7 +424,7 @@ bool CAddrDB::LoadAddresses() while (fgets(psz, sizeof(psz), filein)) { CAddress addr(psz, NODE_NETWORK); - if (addr.ip != 0) + if (addr.IsValid()) { AddAddress(*this, addr); mapIRCAddresses.insert(make_pair(addr.GetKey(), addr)); @@ -676,10 +679,10 @@ void ThreadFlushWalletDB(void* parg) { // Flush wallet.dat so it's self contained nLastFlushed == nWalletDBUpdated; - int64 nStart = PerformanceCounter(); + int64 nStart = GetTimeMillis(); dbenv.txn_checkpoint(0, 0, 0); dbenv.lsn_reset(strFile.c_str(), 0); - printf("Flushed wallet.dat %15"PRI64d"\n", PerformanceCounter() - nStart); + printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart); mapFileUseCount.erase(mi++); } } -- cgit v1.2.3