Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/bdb.h
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> envIn, | ||||
: nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), | : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), | ||||
nLastWalletUpdate(0), env(std::move(envIn)), | nLastWalletUpdate(0), env(std::move(envIn)), | ||||
strFile(std::move(filename)) { | strFile(std::move(filename)) { | ||||
auto inserted = | auto inserted = | ||||
this->env->m_databases.emplace(strFile, std::ref(*this)); | this->env->m_databases.emplace(strFile, std::ref(*this)); | ||||
assert(inserted.second); | assert(inserted.second); | ||||
} | } | ||||
~BerkeleyDatabase() { | ~BerkeleyDatabase(); | ||||
if (env) { | |||||
size_t erased = env->m_databases.erase(strFile); | |||||
assert(erased == 1); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Rewrite the entire database on disk, with the exception of key pszSkip if | * Rewrite the entire database on disk, with the exception of key pszSkip if | ||||
* non-zero | * non-zero | ||||
*/ | */ | ||||
bool Rewrite(const char *pszSkip = nullptr); | bool Rewrite(const char *pszSkip = nullptr); | ||||
/** | /** | ||||
* Back up the entire database to a file. | * Back up the entire database to a file. | ||||
*/ | */ | ||||
bool Backup(const std::string &strDest) const; | bool Backup(const std::string &strDest) const; | ||||
/** | /** | ||||
* Make sure all changes are flushed to disk. | * Make sure all changes are flushed to database file. | ||||
*/ | */ | ||||
void Flush(bool shutdown); | void Flush(); | ||||
/* | /** | ||||
* Flush to the database file and close the database. | |||||
* Also close the environment if no other databases are open in it. | |||||
*/ | |||||
void Close(); | |||||
/** | |||||
* flush the wallet passively (TRY_LOCK) | * flush the wallet passively (TRY_LOCK) | ||||
* ideal to be called periodically | * ideal to be called periodically | ||||
*/ | */ | ||||
bool PeriodicFlush(); | bool PeriodicFlush(); | ||||
void IncrementUpdateCounter(); | void IncrementUpdateCounter(); | ||||
void ReloadDbEnv(); | void ReloadDbEnv(); | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |