From 978f0784648d859552fc98382f9f7ba8301858a6 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Tue, 10 Sep 2024 03:45:44 +0100 Subject: [PATCH] Using path.string().c_str() which supports UTF-16 paths. Use single lmdb::tx implementation. --- nano/core_test/wallet.cpp | 2 +- nano/node/wallet.cpp | 3 ++- nano/store/lmdb/lmdb.cpp | 13 ++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/nano/core_test/wallet.cpp b/nano/core_test/wallet.cpp index d777c80f0c..834f9e9869 100644 --- a/nano/core_test/wallet.cpp +++ b/nano/core_test/wallet.cpp @@ -21,7 +21,7 @@ auto create_wallet_env () -> ::lmdb::env nano::store::lmdb::options::make ().apply (env); auto path = nano::unique_path () / "wallet.ldb"; std::filesystem::create_directories (path); - env.open (path.c_str ()); + env.open (path.string ().c_str ()); return env; } diff --git a/nano/node/wallet.cpp b/nano/node/wallet.cpp index 81f4144ef1..7ad999ab13 100644 --- a/nano/node/wallet.cpp +++ b/nano/node/wallet.cpp @@ -1790,12 +1790,13 @@ nano::store::iterator nano::wallet_store::end { return store::iterator (nullptr); } + nano::mdb_wallets_store::mdb_wallets_store (std::filesystem::path const & path_a, nano::lmdb_config const & lmdb_config_a) : environment (::lmdb::env::create ()) { auto options = nano::store::lmdb::options::make ().set_config (lmdb_config_a).override_config_sync (nano::lmdb_config::sync_strategy::always).override_config_map_size (1ULL * 1024 * 1024 * 1024); options.apply (environment); - environment.open (path_a.c_str (), options.flags ()); + environment.open (path_a.string ().c_str (), options.flags ()); } bool nano::mdb_wallets_store::init_error () const diff --git a/nano/store/lmdb/lmdb.cpp b/nano/store/lmdb/lmdb.cpp index d53422439f..6caeec09e3 100644 --- a/nano/store/lmdb/lmdb.cpp +++ b/nano/store/lmdb/lmdb.cpp @@ -15,11 +15,6 @@ #include -MDB_txn * nano::store::lmdb::tx (store::transaction const & transaction_a) -{ - return static_cast (transaction_a.get_handle ()); -} - nano::store::lmdb::component::component (nano::logger & logger_a, std::filesystem::path const & path_a, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) : // clang-format off nano::store::component{ @@ -54,7 +49,7 @@ nano::store::lmdb::component::component (nano::logger & logger_a, std::filesyste auto options = nano::store::lmdb::options::make ().set_config (lmdb_config_a).set_use_no_mem_init (true); options.apply (env); debug_assert (path_a.filename () == "data.ldb"); - env.open (path_a.c_str (), options.flags ()); + env.open (path_a.string ().c_str (), options.flags ()); if (!error) { auto is_fully_upgraded = false; @@ -67,7 +62,7 @@ nano::store::lmdb::component::component (nano::logger & logger_a, std::filesyste is_fully_upgraded = (version.get (transaction) == version_current); ::lmdb::dbi_close (env, version_store.meta_handle); } - catch (::lmdb::not_found_error & e) + catch (::lmdb::not_found_error &) { is_fresh_db = true; } @@ -139,7 +134,7 @@ bool nano::store::lmdb::component::vacuum_after_upgrade (std::filesystem::path c .set_use_no_mem_init (true); env = ::lmdb::env::create (); options.apply (env); - env.open (path_a.c_str (), options.flags ()); + env.open (path_a.string ().c_str (), options.flags ()); auto transaction = tx_begin_read (); open_databases (transaction, 0); } @@ -379,7 +374,7 @@ int nano::store::lmdb::component::drop (store::write_transaction const & transac table_to_dbi (table_a).drop (tx (transaction_a), true); return 0; } - catch (::lmdb::runtime_error const & e) + catch (::lmdb::runtime_error const &) { return -1; }