aboutsummaryrefslogtreecommitdiff
path: root/src/walletdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r--src/walletdb.cpp39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index e5d57288e..2c4d4c0ef 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
-// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "walletdb.h"
#include "wallet.h"
@@ -13,10 +13,6 @@ using namespace boost;
static uint64 nAccountingEntryNumber = 0;
-extern CCriticalSection cs_db;
-extern map<string, int> mapFileUseCount;
-extern void CloseDb(const string& strFile);
-
//
// CWalletDB
//
@@ -108,7 +104,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
int CWalletDB::LoadWallet(CWallet* pwallet)
{
- pwallet->vchDefaultKey.clear();
+ pwallet->vchDefaultKey = CPubKey();
int nFileVersion = 0;
vector<uint256> vWalletUpgrade;
bool fIsEncrypted = false;
@@ -155,7 +151,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
{
string strAddress;
ssKey >> strAddress;
- ssValue >> pwallet->mapAddressBook[strAddress];
+ ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()];
}
else if (strType == "tx")
{
@@ -350,13 +346,13 @@ void ThreadFlushWalletDB(void* parg)
if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)
{
- TRY_LOCK(cs_db,lockDb);
+ TRY_LOCK(bitdb.cs_db,lockDb);
if (lockDb)
{
// Don't do this if any databases are in use
int nRefCount = 0;
- map<string, int>::iterator mi = mapFileUseCount.begin();
- while (mi != mapFileUseCount.end())
+ map<string, int>::iterator mi = bitdb.mapFileUseCount.begin();
+ while (mi != bitdb.mapFileUseCount.end())
{
nRefCount += (*mi).second;
mi++;
@@ -364,20 +360,18 @@ void ThreadFlushWalletDB(void* parg)
if (nRefCount == 0 && !fShutdown)
{
- map<string, int>::iterator mi = mapFileUseCount.find(strFile);
- if (mi != mapFileUseCount.end())
+ map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
+ if (mi != bitdb.mapFileUseCount.end())
{
- printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("Flushing wallet.dat\n");
nLastFlushed = nWalletDBUpdated;
int64 nStart = GetTimeMillis();
// Flush wallet.dat so it's self contained
- CloseDb(strFile);
- dbenv.txn_checkpoint(0, 0, 0);
- dbenv.lsn_reset(strFile.c_str(), 0);
+ bitdb.CloseDb(strFile);
+ bitdb.CheckpointLSN(strFile);
- mapFileUseCount.erase(mi++);
+ bitdb.mapFileUseCount.erase(mi++);
printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
}
}
@@ -393,14 +387,13 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
while (!fShutdown)
{
{
- LOCK(cs_db);
- if (!mapFileUseCount.count(wallet.strWalletFile) || mapFileUseCount[wallet.strWalletFile] == 0)
+ LOCK(bitdb.cs_db);
+ if (!bitdb.mapFileUseCount.count(wallet.strWalletFile) || bitdb.mapFileUseCount[wallet.strWalletFile] == 0)
{
// Flush log data to the dat file
- CloseDb(wallet.strWalletFile);
- dbenv.txn_checkpoint(0, 0, 0);
- dbenv.lsn_reset(wallet.strWalletFile.c_str(), 0);
- mapFileUseCount.erase(wallet.strWalletFile);
+ bitdb.CloseDb(wallet.strWalletFile);
+ bitdb.CheckpointLSN(wallet.strWalletFile);
+ bitdb.mapFileUseCount.erase(wallet.strWalletFile);
// Copy wallet.dat
filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;