Stop endlessly asking the user for password after refreshing

This commit is contained in:
Doyle 2019-12-18 16:22:44 +11:00
parent 6d71d2fd6e
commit 644557d44d
4 changed files with 21 additions and 6 deletions

View file

@ -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 // can't ask for password from a background thread
if (!m_in_manual_refresh.load(std::memory_order_relaxed)) if (!m_in_manual_refresh.load(std::memory_order_relaxed))
{ {
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; message_writer(console_color_red, false) << boost::format(tr("Password needed %s")) % reason;
m_cmd_binder.print_prompt(); m_cmd_binder.print_prompt();
}
return boost::none; return boost::none;
} }
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
rdln::suspend_readline pause_readline; rdln::suspend_readline pause_readline;
#endif #endif
std::string msg = tr("Enter password"); std::string msg = tr("Enter password ");
if (reason && *reason) if (reason && *reason)
msg += reason; msg += reason;
auto pwd_container = tools::password_container::prompt(false, msg.c_str()); auto pwd_container = tools::password_container::prompt(false, msg.c_str());

View file

@ -426,6 +426,8 @@ namespace cryptonote
uint32_t m_current_subaddress_account; uint32_t m_current_subaddress_account;
bool m_long_payment_id_support; bool m_long_payment_id_support;
std::atomic<uint64_t> m_password_asked_on_height;
crypto::hash m_password_asked_on_checksum;
// MMS // MMS
mms::message_store& get_message_store() const { return m_wallet->get_message_store(); }; mms::message_store& get_message_store() const { return m_wallet->get_message_store(); };

View file

@ -2899,8 +2899,7 @@ void wallet2::update_pool_state(bool refreshed)
std::vector<crypto::hash> tx_hashes; 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); 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); tx_hashes = m_long_poll_tx_pool_cache;
m_long_poll_tx_pool_cache.clear();
} }
auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() { auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() {

View file

@ -1337,6 +1337,12 @@ private:
bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false); 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::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 // 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 // the daemon detects a change in the contents of the txpool by comparing
// our last tx pool checksum with theirs. // our last tx pool checksum with theirs.
@ -1674,7 +1680,7 @@ private:
std::recursive_mutex m_long_poll_mutex; std::recursive_mutex m_long_poll_mutex;
epee::net_utils::http::http_simple_client m_long_poll_client; 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; std::vector<crypto::hash> m_long_poll_tx_pool_cache;
crypto::hash m_long_poll_tx_pool_checksum = {}; crypto::hash m_long_poll_tx_pool_checksum = {};