mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
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
This commit is contained in:
19
db.cpp
19
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++);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user