mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Add MakeBerkeleyRODatabase
Implements MakeBerkeleyRODatabase and adds DatabaseFormat::BERKELEY_RO so that MakeDatabase can use BerkeleyRO as the backend database.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user