diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-06-17 12:25:22 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-06-17 12:31:29 -0400 |
commit | 45c08f8a7b89dda6afb7d7cf9573a8ae8290ac92 (patch) | |
tree | 714f6ecf6acd0250c62dca1bd5a0629d00c0df85 /src/wallet | |
parent | 39bd9ddb8783807b9cde6288233e86ad7c85d61f (diff) |
Add Create*WalletDatabase functions
These functions doing the same things as WalletDatabase::Create,
CreateMock, and CreateDummy
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/walletdb.cpp | 19 | ||||
-rw-r--r-- | src/wallet/walletdb.h | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 2f6c2b883a..6f38398076 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1023,3 +1023,22 @@ bool IsWalletLoaded(const fs::path& wallet_path) { return IsBDBWalletLoaded(wallet_path); } + +/** Return object for accessing database at specified path. */ +std::unique_ptr<BerkeleyDatabase> CreateWalletDatabase(const fs::path& path) +{ + std::string filename; + return MakeUnique<BerkeleyDatabase>(GetWalletEnv(path, filename), std::move(filename)); +} + +/** Return object for accessing dummy database with no read/write capabilities. */ +std::unique_ptr<BerkeleyDatabase> CreateDummyWalletDatabase() +{ + return MakeUnique<BerkeleyDatabase>(); +} + +/** Return object for accessing temporary in-memory database. */ +std::unique_ptr<BerkeleyDatabase> CreateMockWalletDatabase() +{ + return MakeUnique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), ""); +} diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 1037bd579f..61e0f19e56 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -293,4 +293,13 @@ bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, st /** Return whether a wallet database is currently loaded. */ bool IsWalletLoaded(const fs::path& wallet_path); +/** Return object for accessing database at specified path. */ +std::unique_ptr<BerkeleyDatabase> CreateWalletDatabase(const fs::path& path); + +/** Return object for accessing dummy database with no read/write capabilities. */ +std::unique_ptr<BerkeleyDatabase> CreateDummyWalletDatabase(); + +/** Return object for accessing temporary in-memory database. */ +std::unique_ptr<BerkeleyDatabase> CreateMockWalletDatabase(); + #endif // BITCOIN_WALLET_WALLETDB_H |