wallet: new --offline option

It will avoid connecting to a daemon (so useful for cold signing
using a RPC wallet), and not perform DNS queries.
This commit is contained in:
moneromooo-monero 2019-04-13 09:19:38 +00:00
parent 1f809e7485
commit b18f0b1051
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
5 changed files with 127 additions and 60 deletions

View file

@ -274,6 +274,7 @@ namespace net_utils
reciev_machine_state m_state;
chunked_state m_chunked_state;
std::string m_chunked_cache;
bool m_auto_connect;
critical_section m_lock;
public:
@ -291,6 +292,7 @@ namespace net_utils
, m_state()
, m_chunked_state()
, m_chunked_cache()
, m_auto_connect(true)
, m_lock()
{}
@ -316,6 +318,11 @@ namespace net_utils
m_net_client.set_ssl(std::move(ssl_options));
}
void set_auto_connect(bool auto_connect)
{
m_auto_connect = auto_connect;
}
template<typename F>
void set_connector(F connector)
{
@ -367,6 +374,11 @@ namespace net_utils
CRITICAL_REGION_LOCAL(m_lock);
if(!is_connected())
{
if (!m_auto_connect)
{
MWARNING("Auto connect attempt to " << m_host_buff << ":" << m_port << " disabled");
return false;
}
MDEBUG("Reconnecting...");
if(!connect(timeout))
{