diff options
author | Ava Chow <github@achow101.com> | 2024-01-02 16:36:06 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-05-16 15:03:13 -0400 |
commit | dd57713f6ede3d46e97ee7df87c10001b0bf4c3d (patch) | |
tree | 5745af9d8eda6a58cdfc5b59279d8a760f82f9ff /src/wallet/migrate.cpp | |
parent | 6e50bee67d1d58aecd8a0ce8b7c3f5a7979365f5 (diff) | |
download | bitcoin-dd57713f6ede3d46e97ee7df87c10001b0bf4c3d.tar.xz |
Add MakeBerkeleyRODatabase
Implements MakeBerkeleyRODatabase and adds DatabaseFormat::BERKELEY_RO
so that MakeDatabase can use BerkeleyRO as the backend database.
Diffstat (limited to 'src/wallet/migrate.cpp')
-rw-r--r-- | src/wallet/migrate.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/wallet/migrate.cpp b/src/wallet/migrate.cpp index 44e8b26be5..895cee9e14 100644 --- a/src/wallet/migrate.cpp +++ b/src/wallet/migrate.cpp @@ -5,6 +5,7 @@ #include <crypto/common.h> // For ReadBE32 #include <logging.h> #include <streams.h> +#include <util/translation.h> #include <wallet/migrate.h> #include <optional> @@ -748,4 +749,18 @@ std::unique_ptr<DatabaseCursor> BerkeleyROBatch::GetNewPrefixCursor(Span<const s { return std::make_unique<BerkeleyROCursor>(m_database, prefix); } + +std::unique_ptr<BerkeleyRODatabase> MakeBerkeleyRODatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error) +{ + fs::path data_file = BDBDataFile(path); + try { + std::unique_ptr<BerkeleyRODatabase> db = std::make_unique<BerkeleyRODatabase>(data_file); + status = DatabaseStatus::SUCCESS; + return db; + } catch (const std::runtime_error& e) { + error.original = e.what(); + status = DatabaseStatus::FAILED_LOAD; + return nullptr; + } +} } // namespace wallet |