aboutsummaryrefslogtreecommitdiff
path: root/src/walletdb.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2012-05-22 17:45:00 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-05-22 17:45:00 -0400
commit0134a1c08ce237b41470e62841af193e8a1e9457 (patch)
treedb38fb1b7343857e7df5c4698e2b9a821be0c36f /src/walletdb.cpp
parent5d0f7c4f47e6b9aa382846dd9b4a034e724d461a (diff)
parentffe8b77a617efd802a9d4ba7e42b163fbd9a250b (diff)
Merge branch 'dbenv' into tmp
Conflicts: src/db.cpp
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r--src/walletdb.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 86cab4ab2b..2d44e4982f 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -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
//
@@ -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,19 +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("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);
}
}
@@ -392,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;