From 99cef996c788755af95a0a614d7154a30928d4b9 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Wed, 21 Oct 2009 01:08:05 +0000 Subject: flush wallet.dat, multi-proc, reorg options, revert to startup folder shortcut git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@15 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- db.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'db.cpp') diff --git a/db.cpp b/db.cpp index 6607ff5961..a9f5b7953c 100644 --- a/db.cpp +++ b/db.cpp @@ -453,11 +453,7 @@ bool CAddrDB::LoadAddresses() } } - //// debug print - printf("mapAddresses:\n"); - foreach(const PAIRTYPE(vector, CAddress)& item, mapAddresses) - item.second.print(); - printf("-----\n"); + printf("Loaded %d addresses\n", mapAddresses.size()); // Fix for possible bug that manifests in mapAddresses.count in irc.cpp, // just need to call count here and it doesn't happen there. The bug was the @@ -501,6 +497,26 @@ bool CReviewDB::WriteReviews(uint256 hash, const vector& vReviews) // CWalletDB // +CWalletDB::~CWalletDB() +{ + // Flush whenever all handles to wallet.dat are closed + Close(); + CRITICAL_BLOCK(cs_db) + { + map::iterator mi = mapFileUseCount.find(strFile); + if (mi != mapFileUseCount.end()) + { + int nRefCount = (*mi).second; + if (nRefCount == 0) + { + dbenv.txn_checkpoint(0, 0, 0); + dbenv.lsn_reset(strFile.c_str(), 0); + mapFileUseCount.erase(mi++); + } + } + } +} + bool CWalletDB::LoadWallet(vector& vchDefaultKeyRet) { vchDefaultKeyRet.clear(); @@ -568,34 +584,51 @@ bool CWalletDB::LoadWallet(vector& vchDefaultKeyRet) { ssValue >> vchDefaultKeyRet; } - else if (strType == "setting") /// or settings or option or options or config? + else if (strType == "setting") { string strKey; ssKey >> strKey; + + // Menu state + if (strKey == "fShowGenerated") ssValue >> fShowGenerated; if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins; + + // Options if (strKey == "nTransactionFee") ssValue >> nTransactionFee; if (strKey == "addrIncoming") ssValue >> addrIncoming; - if (strKey == "minimizeToTray") ssValue >> minimizeToTray; - if (strKey == "closeToTray") ssValue >> closeToTray; - if (strKey == "startOnSysBoot") ssValue >> startOnSysBoot; - if (strKey == "askBeforeClosing") ssValue >> askBeforeClosing; - if (strKey == "alwaysShowTrayIcon") ssValue >> alwaysShowTrayIcon; + if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors; + if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors; + if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray; + if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; } } } + printf("fShowGenerated = %d\n", fShowGenerated); printf("fGenerateBitcoins = %d\n", fGenerateBitcoins); printf("nTransactionFee = %I64d\n", nTransactionFee); printf("addrIncoming = %s\n", addrIncoming.ToString().c_str()); + printf("fMinimizeToTray = %d\n", fMinimizeToTray); + printf("fMinimizeOnClose = %d\n", fMinimizeOnClose); + + // The transaction fee setting won't be needed for many years to come. + // Setting it to zero here in case they set it to something in an earlier version. + if (nTransactionFee != 0) + { + nTransactionFee = 0; + WriteSetting("nTransactionFee", nTransactionFee); + } return true; } -bool LoadWallet() +bool LoadWallet(bool& fFirstRunRet) { + fFirstRunRet = false; vector vchDefaultKey; if (!CWalletDB("cr").LoadWallet(vchDefaultKey)) return false; + fFirstRunRet = vchDefaultKey.empty(); if (mapKeys.count(vchDefaultKey)) { -- cgit v1.2.3