1
0
Fork 0
forked from lthn/blockchain

wallets_manager: wallet callback lifetime management fixed

This commit is contained in:
sowle 2024-11-09 19:46:51 +01:00
parent d28a0e1b13
commit 74ef510288
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 4 additions and 1 deletions

View file

@ -1051,7 +1051,8 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
w->set_use_deffered_global_outputs(m_use_deffered_global_outputs);
owr.wallet_id = m_wallet_id_counter++;
w->callback(std::shared_ptr<tools::i_wallet2_callback>(new i_wallet_to_i_backend_adapter(this, owr.wallet_id)));
std::shared_ptr<tools::i_wallet2_callback> w_cb{new i_wallet_to_i_backend_adapter(this, owr.wallet_id)};
w->callback(w_cb);
if (m_remote_node_mode)
{
w->set_core_proxy(m_rpc_proxy);
@ -1112,6 +1113,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
EXCLUSIVE_CRITICAL_REGION_LOCAL(m_wallets_lock);
wallet_vs_options& wo = m_wallets[owr.wallet_id];
**wo.w = w;
wo.w_cb = w_cb;
owr.wallet_file_size = w->get_wallet_file_size();
get_wallet_info(wo, owr.wi);
init_wallet_entry(wo, owr.wallet_id);

View file

@ -55,6 +55,7 @@ public:
{
currency::core_runtime_config core_conf;
epee::locked_object<std::shared_ptr<tools::wallet2>, wallet_lock_time_watching_policy> w;
std::shared_ptr<tools::i_wallet2_callback> w_cb; // not using locked_object here, cuz w_cb is accessed only via it's wallet -- sowle
typedef epee::locked_object<std::shared_ptr<tools::wallet2>, wallet_lock_time_watching_policy>::lock_shared_ptr wallet_lock_object;
std::shared_ptr<tools::wallet_rpc_server> rpc_wrapper; //500 bytes of extra data, we can afford it, to have rpc-like invoke map
std::atomic<bool> do_mining;