forked from lthn/blockchain
attempt to fix a rare deadlock in gui on wallet's refresh
This commit is contained in:
parent
41695ef275
commit
3e26c91643
2 changed files with 13 additions and 11 deletions
|
|
@ -11,11 +11,11 @@
|
|||
#include "currency_core/core_tools.h"
|
||||
//#include <codecvt>
|
||||
|
||||
#define GET_WALLET_OPT_BY_ID(wallet_id, name) \
|
||||
#define GET_WALLET_OPT_BY_ID(wallet_id, name) \
|
||||
CRITICAL_REGION_LOCAL(m_wallets_lock); \
|
||||
auto it = m_wallets.find(wallet_id); \
|
||||
if (it == m_wallets.end()) \
|
||||
return API_RETURN_CODE_WALLET_WRONG_ID; \
|
||||
if (it == m_wallets.end()) \
|
||||
return API_RETURN_CODE_WALLET_WRONG_ID; \
|
||||
auto& name = it->second;
|
||||
|
||||
#define GET_WALLET_BY_ID(wallet_id, name) \
|
||||
|
|
@ -551,8 +551,12 @@ void daemon_backend::init_wallet_entry(wallet_vs_options& wo, uint64_t id)
|
|||
wo.core_conf = currency::get_default_core_runtime_config();
|
||||
else
|
||||
wo.core_conf = m_ccore.get_blockchain_storage().get_core_runtime_config();
|
||||
}
|
||||
|
||||
// update wallet log prefix for further usage
|
||||
if (m_wallet_log_prefixes.size() <= id)
|
||||
m_wallet_log_prefixes.resize(id + 1);
|
||||
m_wallet_log_prefixes[id] = std::string("[") + epee::string_tools::num_to_string_fast(id) + ":" + wo.w->get()->get_account().get_public_address_str().substr(0, 6) + "] ";
|
||||
}
|
||||
|
||||
|
||||
std::string daemon_backend::get_tx_pool_info(currency::COMMAND_RPC_GET_POOL_INFO::response& res)
|
||||
|
|
@ -679,7 +683,7 @@ std::string daemon_backend::open_wallet(const std::wstring& path, const std::str
|
|||
**wo.w = w;
|
||||
get_wallet_info(wo, owr.wi);
|
||||
init_wallet_entry(wo, owr.wallet_id);
|
||||
//update_wallets_info();
|
||||
|
||||
return return_code;
|
||||
}
|
||||
|
||||
|
|
@ -833,6 +837,7 @@ std::string daemon_backend::close_wallet(size_t wallet_id)
|
|||
|
||||
it->second.w->get()->store();
|
||||
m_wallets.erase(it);
|
||||
m_wallet_log_prefixes[wallet_id] = std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":CLOSED] ";
|
||||
}
|
||||
|
||||
catch (const std::exception& e)
|
||||
|
|
@ -1600,11 +1605,7 @@ daemon_backend::wallet_vs_options::~wallet_vs_options()
|
|||
|
||||
std::string daemon_backend::get_wallet_log_prefix(size_t wallet_id) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_wallets_lock);
|
||||
auto it = m_wallets.find(wallet_id);
|
||||
if (it == m_wallets.end())
|
||||
return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":???]";
|
||||
|
||||
return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":" + it->second.w->get()->get_account().get_public_address_str().substr(0, 6) + "]";
|
||||
CHECK_AND_ASSERT_MES(wallet_id < m_wallet_log_prefixes.size(), std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":???] ", "wallet prefix is not found for id " << wallet_id);
|
||||
return m_wallet_log_prefixes[wallet_id];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ private:
|
|||
|
||||
|
||||
std::map<size_t, wallet_vs_options> m_wallets;
|
||||
std::vector<std::string> m_wallet_log_prefixes;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue