aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-05-14 12:33:34 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-05-19 20:44:31 -0400
commit24b57e3c6a1e5c00e10ee19803dd86d821ffebb2 (patch)
tree64e6784b3f45cddfe70e83eb0360b56340131844
parentcd9696fc97fc06831c1edede62a063028f2afe75 (diff)
Create CDBEnv::TxnBegin(), and use it in CDB::TxnBegin()
-rw-r--r--src/db.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/db.h b/src/db.h
index e2983e0787..aff5e367b4 100644
--- a/src/db.h
+++ b/src/db.h
@@ -50,6 +50,15 @@ public:
void Flush(bool fShutdown);
void CheckpointLSN(std::string strFile);
void SetDetach(bool fDetachDB_) { fDetachDB = fDetachDB_; }
+
+ DbTxn *TxnBegin(DbTxn *baseTxn, int flags=DB_TXN_WRITE_NOSYNC)
+ {
+ DbTxn* ptxn = NULL;
+ int ret = dbenv.txn_begin(baseTxn, &ptxn, flags);
+ if (!ptxn || ret != 0)
+ return NULL;
+ return ptxn;
+ }
};
extern CDBEnv bitdb;
@@ -237,9 +246,8 @@ public:
{
if (!pdb)
return false;
- DbTxn* ptxn = NULL;
- int ret = bitdb.dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_WRITE_NOSYNC);
- if (!ptxn || ret != 0)
+ DbTxn* ptxn = bitdb.TxnBegin(GetTxn());
+ if (!ptxn)
return false;
vTxn.push_back(ptxn);
return true;