Skip to content

Commit

Permalink
Using path.string().c_str() which supports UTF-16 paths.
Browse files Browse the repository at this point in the history
Use single lmdb::tx implementation.
  • Loading branch information
clemahieu committed Sep 10, 2024
1 parent 8cdedc2 commit 978f078
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,12 +1790,13 @@ nano::store::iterator<nano::account, nano::wallet_value> nano::wallet_store::end
{
return store::iterator<nano::account, nano::wallet_value> (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
Expand Down
13 changes: 4 additions & 9 deletions nano/store/lmdb/lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@

#include <queue>

MDB_txn * nano::store::lmdb::tx (store::transaction const & transaction_a)
{
return static_cast<MDB_txn *> (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{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 978f078

Please sign in to comment.