Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/bdb.h
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
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 disk. | ||||
*/ | */ | ||||
void Flush(bool shutdown); | void Flush(bool shutdown); | ||||
/* | |||||
* flush the wallet passively (TRY_LOCK) | |||||
* ideal to be called periodically | |||||
*/ | |||||
bool PeriodicFlush(); | |||||
void IncrementUpdateCounter(); | void IncrementUpdateCounter(); | ||||
void ReloadDbEnv(); | void ReloadDbEnv(); | ||||
std::atomic<unsigned int> nUpdateCounter; | std::atomic<unsigned int> nUpdateCounter; | ||||
unsigned int nLastSeen; | unsigned int nLastSeen; | ||||
unsigned int nLastFlushed; | unsigned int nLastFlushed; | ||||
int64_t nLastWalletUpdate; | int64_t nLastWalletUpdate; | ||||
/** Verifies the environment and database file */ | |||||
bool Verify(bilingual_str &error); | |||||
/** | /** | ||||
* Pointer to shared database environment. | * Pointer to shared database environment. | ||||
* | * | ||||
* Normally there is only one BerkeleyDatabase object per | * Normally there is only one BerkeleyDatabase object per | ||||
* BerkeleyEnvivonment, but in the special, backwards compatible case where | * BerkeleyEnvivonment, but in the special, backwards compatible case where | ||||
* multiple wallet BDB data files are loaded from the same directory, this | * multiple wallet BDB data files are loaded from the same directory, this | ||||
* will point to a shared instance that gets freed when the last data file | * will point to a shared instance that gets freed when the last data file | ||||
* is closed. | * is closed. | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public: | ||||
~BerkeleyBatch() { Close(); } | ~BerkeleyBatch() { Close(); } | ||||
BerkeleyBatch(const BerkeleyBatch &) = delete; | BerkeleyBatch(const BerkeleyBatch &) = delete; | ||||
BerkeleyBatch &operator=(const BerkeleyBatch &) = delete; | BerkeleyBatch &operator=(const BerkeleyBatch &) = delete; | ||||
void Flush(); | void Flush(); | ||||
void Close(); | void Close(); | ||||
/* | |||||
* flush the wallet passively (TRY_LOCK)i | |||||
* ideal to be called periodically | |||||
*/ | |||||
static bool PeriodicFlush(BerkeleyDatabase &database); | |||||
/* verifies the database environment */ | |||||
static bool VerifyEnvironment(const fs::path &file_path, | |||||
bilingual_str &errorStr); | |||||
/* verifies the database file */ | |||||
static bool VerifyDatabaseFile(const fs::path &file_path, | |||||
bilingual_str &errorStr); | |||||
template <typename K, typename T> bool Read(const K &key, T &value) { | template <typename K, typename T> bool Read(const K &key, T &value) { | ||||
if (!pdb) { | if (!pdb) { | ||||
return false; | return false; | ||||
} | } | ||||
// Key | // Key | ||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION); | CDataStream ssKey(SER_DISK, CLIENT_VERSION); | ||||
ssKey.reserve(1000); | ssKey.reserve(1000); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | template <typename K> bool Exists(const K &key) { | ||||
return (ret == 0); | return (ret == 0); | ||||
} | } | ||||
Dbc *GetCursor(); | Dbc *GetCursor(); | ||||
int ReadAtCursor(Dbc *pcursor, CDataStream &ssKey, CDataStream &ssValue); | int ReadAtCursor(Dbc *pcursor, CDataStream &ssKey, CDataStream &ssValue); | ||||
bool TxnBegin(); | bool TxnBegin(); | ||||
bool TxnCommit(); | bool TxnCommit(); | ||||
bool TxnAbort(); | bool TxnAbort(); | ||||
static bool Rewrite(BerkeleyDatabase &database, | |||||
const char *pszSkip = nullptr); | |||||
}; | }; | ||||
#endif // BITCOIN_WALLET_BDB_H | #endif // BITCOIN_WALLET_BDB_H |