mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
refactor: Consolidate redundant wallet database path and exists functions
No change in behavior. Just remove a little bit of code, reduce macro usage, remove duplicative functions, and make BDB and SQLite implementations more consistent with each other.
This commit is contained in:
parent
6a7a63644c
commit
d70dc89e78
8 changed files with 38 additions and 54 deletions
|
|
@ -17,7 +17,6 @@
|
|||
#include <sqlite3.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static const char* const DATABASE_FILENAME = "wallet.dat";
|
||||
static constexpr int32_t WALLET_SCHEMA_VERSION = 0;
|
||||
|
||||
static Mutex g_sqlite_mutex;
|
||||
|
|
@ -568,17 +567,11 @@ bool SQLiteBatch::TxnAbort()
|
|||
return res == SQLITE_OK;
|
||||
}
|
||||
|
||||
bool ExistsSQLiteDatabase(const fs::path& path)
|
||||
{
|
||||
const fs::path file = path / DATABASE_FILENAME;
|
||||
return fs::symlink_status(file).type() == fs::regular_file && IsSQLiteFile(file);
|
||||
}
|
||||
|
||||
std::unique_ptr<SQLiteDatabase> MakeSQLiteDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error)
|
||||
{
|
||||
const fs::path file = path / DATABASE_FILENAME;
|
||||
try {
|
||||
auto db = MakeUnique<SQLiteDatabase>(path, file);
|
||||
fs::path data_file = SQLiteDataFile(path);
|
||||
auto db = MakeUnique<SQLiteDatabase>(data_file.parent_path(), data_file);
|
||||
if (options.verify && !db->Verify(error)) {
|
||||
status = DatabaseStatus::FAILED_VERIFY;
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue