mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
Stop endlessly asking the user for password after refreshing
This commit is contained in:
parent
6d71d2fd6e
commit
644557d44d
4 changed files with 21 additions and 6 deletions
|
@ -4999,15 +4999,23 @@ boost::optional<epee::wipeable_string> simple_wallet::on_get_password(const char
|
|||
// can't ask for password from a background thread
|
||||
if (!m_in_manual_refresh.load(std::memory_order_relaxed))
|
||||
{
|
||||
message_writer(console_color_red, false) << boost::format(tr("Password needed %s")) % reason;
|
||||
m_cmd_binder.print_prompt();
|
||||
crypto::hash tx_pool_checksum = m_wallet->get_long_poll_tx_pool_checksum();
|
||||
if (m_password_asked_on_height != m_wallet->get_blockchain_current_height() ||
|
||||
m_password_asked_on_checksum != tx_pool_checksum)
|
||||
{
|
||||
m_password_asked_on_height = m_wallet->get_blockchain_current_height();
|
||||
m_password_asked_on_checksum = tx_pool_checksum;
|
||||
|
||||
message_writer(console_color_red, false) << boost::format(tr("Password needed %s")) % reason;
|
||||
m_cmd_binder.print_prompt();
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
rdln::suspend_readline pause_readline;
|
||||
#endif
|
||||
std::string msg = tr("Enter password");
|
||||
std::string msg = tr("Enter password ");
|
||||
if (reason && *reason)
|
||||
msg += reason;
|
||||
auto pwd_container = tools::password_container::prompt(false, msg.c_str());
|
||||
|
|
|
@ -426,6 +426,8 @@ namespace cryptonote
|
|||
uint32_t m_current_subaddress_account;
|
||||
|
||||
bool m_long_payment_id_support;
|
||||
std::atomic<uint64_t> m_password_asked_on_height;
|
||||
crypto::hash m_password_asked_on_checksum;
|
||||
|
||||
// MMS
|
||||
mms::message_store& get_message_store() const { return m_wallet->get_message_store(); };
|
||||
|
|
|
@ -2899,8 +2899,7 @@ void wallet2::update_pool_state(bool refreshed)
|
|||
std::vector<crypto::hash> tx_hashes;
|
||||
{
|
||||
std::lock_guard<decltype(m_long_poll_tx_pool_cache_mutex)> lock(m_long_poll_tx_pool_cache_mutex);
|
||||
tx_hashes = std::move(m_long_poll_tx_pool_cache);
|
||||
m_long_poll_tx_pool_cache.clear();
|
||||
tx_hashes = m_long_poll_tx_pool_cache;
|
||||
}
|
||||
|
||||
auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() {
|
||||
|
|
|
@ -1337,6 +1337,12 @@ private:
|
|||
bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false);
|
||||
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const;
|
||||
|
||||
crypto::hash get_long_poll_tx_pool_checksum() const
|
||||
{
|
||||
std::lock_guard<decltype(m_long_poll_tx_pool_cache_mutex)> lock(m_long_poll_tx_pool_cache_mutex);
|
||||
return m_long_poll_tx_pool_checksum;
|
||||
};
|
||||
|
||||
// long_poll_pool_state is blocking and does NOT return to the caller until
|
||||
// the daemon detects a change in the contents of the txpool by comparing
|
||||
// our last tx pool checksum with theirs.
|
||||
|
@ -1674,7 +1680,7 @@ private:
|
|||
|
||||
std::recursive_mutex m_long_poll_mutex;
|
||||
epee::net_utils::http::http_simple_client m_long_poll_client;
|
||||
std::mutex m_long_poll_tx_pool_cache_mutex;
|
||||
mutable std::mutex m_long_poll_tx_pool_cache_mutex;
|
||||
std::vector<crypto::hash> m_long_poll_tx_pool_cache;
|
||||
crypto::hash m_long_poll_tx_pool_checksum = {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue