Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.cpp
Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | void CDBEnv::CheckpointLSN(const std::string &strFile) { | ||||
if (fMockDb) { | if (fMockDb) { | ||||
return; | return; | ||||
} | } | ||||
dbenv->lsn_reset(strFile.c_str(), 0); | dbenv->lsn_reset(strFile.c_str(), 0); | ||||
} | } | ||||
CDB::CDB(CWalletDBWrapper &dbw, const char *pszMode, bool fFlushOnCloseIn) | CDB::CDB(CWalletDBWrapper &dbw, const char *pszMode, bool fFlushOnCloseIn) | ||||
: pdb(nullptr), activeTxn(nullptr) { | : pdb(nullptr), activeTxn(nullptr) { | ||||
int ret; | |||||
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); | fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); | ||||
fFlushOnClose = fFlushOnCloseIn; | fFlushOnClose = fFlushOnCloseIn; | ||||
env = dbw.env; | env = dbw.env; | ||||
if (dbw.IsDummy()) { | if (dbw.IsDummy()) { | ||||
return; | return; | ||||
} | } | ||||
const std::string &strFilename = dbw.strFile; | const std::string &strFilename = dbw.strFile; | ||||
bool fCreate = strchr(pszMode, 'c') != nullptr; | bool fCreate = strchr(pszMode, 'c') != nullptr; | ||||
unsigned int nFlags = DB_THREAD; | unsigned int nFlags = DB_THREAD; | ||||
if (fCreate) { | if (fCreate) { | ||||
nFlags |= DB_CREATE; | nFlags |= DB_CREATE; | ||||
} | } | ||||
{ | { | ||||
LOCK(cs_db); | LOCK(cs_db); | ||||
if (!env->Open(false /* retry */)) { | if (!env->Open(false /* retry */)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"CDB: Failed to open database environment."); | "CDB: Failed to open database environment."); | ||||
} | } | ||||
pdb = env->mapDb[strFilename]; | pdb = env->mapDb[strFilename]; | ||||
if (pdb == nullptr) { | if (pdb == nullptr) { | ||||
int ret; | |||||
std::unique_ptr<Db> pdb_temp = | std::unique_ptr<Db> pdb_temp = | ||||
std::make_unique<Db>(env->dbenv.get(), 0); | std::make_unique<Db>(env->dbenv.get(), 0); | ||||
bool fMockDb = env->IsMock(); | bool fMockDb = env->IsMock(); | ||||
if (fMockDb) { | if (fMockDb) { | ||||
DbMpoolFile *mpf = pdb_temp->get_mpf(); | DbMpoolFile *mpf = pdb_temp->get_mpf(); | ||||
ret = mpf->set_flags(DB_MPOOL_NOFILE, 1); | ret = mpf->set_flags(DB_MPOOL_NOFILE, 1); | ||||
if (ret != 0) { | if (ret != 0) { | ||||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |