Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wallets::start() function for deferred start. #3568

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ void nano::node::start ()
{
port_mapping.start ();
}
wallets.start ();
if (config.frontiers_confirmation != nano::frontiers_confirmation_mode::disabled)
{
workers.push_task ([this_l = shared ()] () {
Expand Down
14 changes: 9 additions & 5 deletions nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,7 @@ nano::wallets::wallets (bool error_a, nano::node & node_a) :
kdf{ node_a.config.network_params.kdf_work },
node (node_a),
env (boost::polymorphic_downcast<nano::mdb_wallets_store *> (node_a.wallets_store_impl.get ())->environment),
stopped (false),
thread ([this] () {
nano::thread_role::set (nano::thread_role::name::wallet_actions);
do_wallet_actions ();
})
stopped (false)
{
nano::unique_lock<nano::mutex> lock (mutex);
if (!error_a)
Expand Down Expand Up @@ -1606,6 +1602,14 @@ void nano::wallets::stop ()
}
}

void nano::wallets::start ()
{
thread = std::thread{ [this] () {
nano::thread_role::set (nano::thread_role::name::wallet_actions);
do_wallet_actions ();
} };
}

nano::write_transaction nano::wallets::tx_begin_write ()
{
return env.tx_begin_write ();
Expand Down
1 change: 1 addition & 0 deletions nano/node/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class wallets final
void queue_wallet_action (nano::uint128_t const &, std::shared_ptr<nano::wallet> const &, std::function<void (nano::wallet &)>);
void foreach_representative (std::function<void (nano::public_key const &, nano::raw_key const &)> const &);
bool exists (nano::transaction const &, nano::account const &);
void start ();
void stop ();
void clear_send_ids (nano::transaction const &);
nano::wallet_representatives reps () const;
Expand Down