mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-05 10:12:48 +01:00
Merge #20202: wallet: Make BDB support optional
d52f502b1eFix mock SQLiteDatabases (Andrew Chow)99309ab3e9Allow disabling BDB in configure with --without-bdb (Andrew Chow)ee47f11f73GUI: Force descriptor wallets when BDB is not compiled (Andrew Chow)71e40b33bdRPC: Require descriptors=True for createwallet when BDB is not compiled (Andrew Chow)6ebc41bf9cEnforce salvage is only for BDB wallets (Andrew Chow)a58b719cf7Do not compile BDB things when USE_BDB is defined (Andrew Chow)b33af48210Include wallet/bdb.h where it is actually being used (Andrew Chow) Pull request description: Adds a `--without-bdb` option to `configure` which disables the compilation of the BDB stuff. Legacy wallets will not be created when BDB is not compiled. A legacy-sqlite wallet can be loaded, but we will not create them. Based on #20156 to resolve the situation where both `--without-sqlite` and `--without-bdb` are provided. In that case, the wallet is disabled and `--disable-wallet` is effectively set. ACKs for top commit: laanwj: Code review ACKd52f502b1eTree-SHA512: 5a92ba7a542acc2e27003e9d4e5940e0d02d5c1f110db06cdcab831372bfd83e8d89c269caff31dd5bff062c1cf5f04683becff12bd23a33be731676f346553d
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
#include <util/system.h>
|
||||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
#ifdef USE_BDB
|
||||
#include <wallet/bdb.h>
|
||||
#endif
|
||||
#ifdef USE_SQLITE
|
||||
#include <wallet/sqlite.h>
|
||||
#endif
|
||||
@@ -1011,9 +1013,11 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
|
||||
Optional<DatabaseFormat> format;
|
||||
if (exists) {
|
||||
#ifdef USE_BDB
|
||||
if (ExistsBerkeleyDatabase(path)) {
|
||||
format = DatabaseFormat::BERKELEY;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SQLITE
|
||||
if (ExistsSQLiteDatabase(path)) {
|
||||
if (format) {
|
||||
@@ -1052,15 +1056,31 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
// Format is not set when a db doesn't already exist, so use the format specified by the options if it is set.
|
||||
if (!format && options.require_format) format = options.require_format;
|
||||
|
||||
// If the format is not specified or detected, choose the default format based on what is available. We prefer BDB over SQLite for now.
|
||||
if (!format) {
|
||||
#ifdef USE_SQLITE
|
||||
if (format && format == DatabaseFormat::SQLITE) {
|
||||
return MakeSQLiteDatabase(path, options, status, error);
|
||||
}
|
||||
#else
|
||||
assert(format != DatabaseFormat::SQLITE);
|
||||
format = DatabaseFormat::SQLITE;
|
||||
#endif
|
||||
#ifdef USE_BDB
|
||||
format = DatabaseFormat::BERKELEY;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (format == DatabaseFormat::SQLITE) {
|
||||
#ifdef USE_SQLITE
|
||||
return MakeSQLiteDatabase(path, options, status, error);
|
||||
#endif
|
||||
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support SQLite database format.", path.string()));
|
||||
status = DatabaseStatus::FAILED_BAD_FORMAT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef USE_BDB
|
||||
return MakeBerkeleyDatabase(path, options, status, error);
|
||||
#endif
|
||||
error = Untranslated(strprintf("Failed to open database path '%s'. Build does not support Berkeley DB database format.", path.string()));
|
||||
status = DatabaseStatus::FAILED_BAD_FORMAT;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Return object for accessing dummy database with no read/write capabilities. */
|
||||
@@ -1072,5 +1092,9 @@ std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase()
|
||||
/** Return object for accessing temporary in-memory database. */
|
||||
std::unique_ptr<WalletDatabase> CreateMockWalletDatabase()
|
||||
{
|
||||
#ifdef USE_BDB
|
||||
return MakeUnique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), "");
|
||||
#elif USE_SQLITE
|
||||
return MakeUnique<SQLiteDatabase>("", "", true);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user