mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01: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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user