diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2009-11-01 01:16:51 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2009-11-01 01:16:51 +0000 |
commit | e66ec79b18717bf83b7dbbe54f844b4463dabdeb (patch) | |
tree | 8120216e7ebfdc54244835dfa5650f1181b57025 /db.cpp | |
parent | 99142385daea73bb2c8fadf44b6d36df31813fb0 (diff) |
move debug.log and db.log to data dir, portable GetDataDir, optimize GetBalance, fix repaint bogdown, -addnode and -? switches
Diffstat (limited to 'db.cpp')
-rw-r--r-- | db.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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++);
}
}
|