aboutsummaryrefslogtreecommitdiff
path: root/src/walletdb.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-05-13 21:37:39 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-05-19 20:43:19 -0400
commitcd9696fc97fc06831c1edede62a063028f2afe75 (patch)
tree8a1ce2483296e0370a2986bb781c4f55d4f01e64 /src/walletdb.cpp
parentb52a27053850590e0ac8f1431a9aad50b7beffee (diff)
downloadbitcoin-cd9696fc97fc06831c1edede62a063028f2afe75.tar.xz
Encapsulate BDB environment inside new CDBEnv class
Cleans up and organizes several scattered functions and variables related to the BDB env. Class CDBInit() existed to provide a guaranteed-via-C++-destructor cleanup of the db environment. A formal CDBEnv class provides all of this inside a single wrapper.
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r--src/walletdb.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 7849828a51..4bdb7e23d1 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -13,7 +13,6 @@ using namespace boost;
static uint64 nAccountingEntryNumber = 0;
-extern CCriticalSection cs_db;
extern map<string, int> mapFileUseCount;
extern void CloseDb(const string& strFile);
@@ -350,7 +349,7 @@ 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
@@ -373,8 +372,7 @@ void ThreadFlushWalletDB(void* parg)
// Flush wallet.dat so it's self contained
CloseDb(strFile);
- dbenv.txn_checkpoint(0, 0, 0);
- dbenv.lsn_reset(strFile.c_str(), 0);
+ bitdb.CheckpointLSN(strFile);
mapFileUseCount.erase(mi++);
printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
@@ -392,13 +390,12 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
while (!fShutdown)
{
{
- LOCK(cs_db);
+ LOCK(bitdb.cs_db);
if (!mapFileUseCount.count(wallet.strWalletFile) || 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);
+ bitdb.CheckpointLSN(wallet.strWalletFile);
mapFileUseCount.erase(wallet.strWalletFile);
// Copy wallet.dat