Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.h
Show All 36 Lines | |||||
class CKeyPool; | class CKeyPool; | ||||
class CMasterKey; | class CMasterKey; | ||||
class CScript; | class CScript; | ||||
class CWallet; | class CWallet; | ||||
class CWalletTx; | class CWalletTx; | ||||
class uint160; | class uint160; | ||||
class uint256; | class uint256; | ||||
/** Backend-agnostic database type. */ | |||||
using WalletDatabase = BerkeleyDatabase; | |||||
/** Error statuses for the wallet database */ | /** Error statuses for the wallet database */ | ||||
enum class DBErrors { | enum class DBErrors { | ||||
LOAD_OK, | LOAD_OK, | ||||
CORRUPT, | CORRUPT, | ||||
NONCRITICAL_ERROR, | NONCRITICAL_ERROR, | ||||
TOO_NEW, | TOO_NEW, | ||||
LOAD_FAIL, | LOAD_FAIL, | ||||
NEED_REWRITE | NEED_REWRITE | ||||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | public: | ||||
//! Begin a new transaction | //! Begin a new transaction | ||||
bool TxnBegin(); | bool TxnBegin(); | ||||
//! Commit current transaction | //! Commit current transaction | ||||
bool TxnCommit(); | bool TxnCommit(); | ||||
//! Abort current transaction | //! Abort current transaction | ||||
bool TxnAbort(); | bool TxnAbort(); | ||||
private: | private: | ||||
std::unique_ptr<BerkeleyBatch> m_batch; | std::unique_ptr<DatabaseBatch> m_batch; | ||||
WalletDatabase &m_database; | WalletDatabase &m_database; | ||||
}; | }; | ||||
//! Compacts BDB state so that wallet.dat is self-contained (if there are | //! Compacts BDB state so that wallet.dat is self-contained (if there are | ||||
//! changes) | //! changes) | ||||
void MaybeCompactWalletDB(); | void MaybeCompactWalletDB(); | ||||
//! Unserialize a given Key-Value pair and load it into the wallet | //! Unserialize a given Key-Value pair and load it into the wallet | ||||
bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue, | bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue, | ||||
std::string &strType, std::string &strErr); | std::string &strType, std::string &strErr); | ||||
/** Return whether a wallet database is currently loaded. */ | /** Return whether a wallet database is currently loaded. */ | ||||
bool IsWalletLoaded(const fs::path &wallet_path); | bool IsWalletLoaded(const fs::path &wallet_path); | ||||
/** Return object for accessing database at specified path. */ | /** Return object for accessing database at specified path. */ | ||||
std::unique_ptr<BerkeleyDatabase> CreateWalletDatabase(const fs::path &path); | std::unique_ptr<WalletDatabase> CreateWalletDatabase(const fs::path &path); | ||||
/** | /** | ||||
* Return object for accessing dummy database with no read/write capabilities. | * Return object for accessing dummy database with no read/write capabilities. | ||||
*/ | */ | ||||
std::unique_ptr<BerkeleyDatabase> CreateDummyWalletDatabase(); | std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase(); | ||||
/** Return object for accessing temporary in-memory database. */ | /** Return object for accessing temporary in-memory database. */ | ||||
std::unique_ptr<BerkeleyDatabase> CreateMockWalletDatabase(); | std::unique_ptr<WalletDatabase> CreateMockWalletDatabase(); | ||||
#endif // BITCOIN_WALLET_WALLETDB_H | #endif // BITCOIN_WALLET_WALLETDB_H |