bfdb399772
Brings in uncommitted work from SAMI-PC E:\repos\triangles
cpp20-modernization branch:
- RocksDB default chain DB + auto-migrate from txleveldb
- SQLite default wallet + non-destructive migration from Berkeley
- Boost.Asio removed from RPC (rpc_httpsocket.h)
- Boost removed from all daemon + GUI code
- New: walletdb-base.h, walletdb-batch.h, walletdb-sqlite.{h,cpp},
walletdb-factory.{h,cpp}, walletmigrate.{h,cpp}
- New tests: chaindb_runtime_tests, chaindb_equivalence_tests,
snapshotnet_tests
- Docs: BOOST-REMOVAL.md, ROCKSDB-DEFAULT-MIGRATION.md,
WALLET-SQLITE-MIGRATION.md
Does not yet build — needs CWalletDB->CWalletBatchTyped rebase in
walletdb.cpp/wallet.cpp/db.cpp and merge with origin/master for
v6 source files (checkpointpublisher, tor/, snapshot/, utxosnapshot,
bootstrap.cpp).
Build flags: -DBUILD_QT=OFF -DUSE_I2P_EMBEDDED=OFF
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
// Copyright (c) 2026 The Triangles developers.
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include "walletdb-base.h"
|
|
#include "walletdb-sqlite.h"
|
|
#include "util.h"
|
|
|
|
#include <cctype>
|
|
#include <filesystem>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
WalletDbKind ResolveWalletDbKind()
|
|
{
|
|
// SQLite is the default wallet backend. Berkeley DB is retained for one
|
|
// release as a fallback (-walletdb=bdb) and as the migration source.
|
|
std::string s = GetArg("-walletdb", std::string("sqlite"));
|
|
for (auto& c : s) c = std::tolower(static_cast<unsigned char>(c));
|
|
|
|
if (s == "sqlite")
|
|
return WalletDbKind::SQLite;
|
|
if (s == "bdb" || s == "berkeley")
|
|
return WalletDbKind::Berkeley;
|
|
|
|
throw std::runtime_error(
|
|
"-walletdb=" + s + " is not a recognized wallet backend. "
|
|
"Valid values: sqlite, bdb.");
|
|
}
|
|
|
|
std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& strFilename,
|
|
std::string& strError)
|
|
{
|
|
const fs::path path = GetDataDir() / strFilename;
|
|
|
|
switch (ResolveWalletDbKind()) {
|
|
case WalletDbKind::SQLite: {
|
|
auto db = std::make_unique<SQLiteDatabase>(path);
|
|
if (!db->Open(strError))
|
|
return nullptr;
|
|
return db;
|
|
}
|
|
case WalletDbKind::Berkeley:
|
|
// The Berkeley backend is still served by the legacy CWalletDB/CDB code
|
|
// path. The thin BerkeleyDatabase adapter that plugs the existing
|
|
// CDBEnv/CDB into this seam is added during CWalletDB integration; see
|
|
// WALLET-SQLITE-MIGRATION.md. Until then, selecting -walletdb=bdb keeps
|
|
// the original code path rather than routing through MakeWalletDatabase.
|
|
strError = "Berkeley backend uses the legacy wallet path; not served by MakeWalletDatabase yet.";
|
|
return nullptr;
|
|
}
|
|
return nullptr; // unreachable
|
|
}
|