mirror of
https://github.com/monero-project/monero.git
synced 2024-12-24 04:29:43 +00:00
fix timeout in check_connection
This commit is contained in:
parent
2806842200
commit
dea53962a3
3 changed files with 7 additions and 5 deletions
|
@ -54,6 +54,8 @@ namespace {
|
||||||
static const int MAX_REFRESH_INTERVAL_MILLIS = 1000 * 60 * 1;
|
static const int MAX_REFRESH_INTERVAL_MILLIS = 1000 * 60 * 1;
|
||||||
// Default refresh interval when connected to remote node
|
// Default refresh interval when connected to remote node
|
||||||
static const int DEFAULT_REMOTE_NODE_REFRESH_INTERVAL_MILLIS = 1000 * 10;
|
static const int DEFAULT_REMOTE_NODE_REFRESH_INTERVAL_MILLIS = 1000 * 10;
|
||||||
|
// Connection timeout 30 sec
|
||||||
|
static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Wallet2CallbackImpl : public tools::i_wallet2_callback
|
struct Wallet2CallbackImpl : public tools::i_wallet2_callback
|
||||||
|
@ -1043,7 +1045,7 @@ bool WalletImpl::verifySignedMessage(const std::string &message, const std::stri
|
||||||
|
|
||||||
bool WalletImpl::connectToDaemon()
|
bool WalletImpl::connectToDaemon()
|
||||||
{
|
{
|
||||||
bool result = m_wallet->check_connection();
|
bool result = m_wallet->check_connection(NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS);
|
||||||
m_status = result ? Status_Ok : Status_Error;
|
m_status = result ? Status_Ok : Status_Error;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
m_errorString = "Error connecting to daemon at " + m_wallet->get_daemon_address();
|
m_errorString = "Error connecting to daemon at " + m_wallet->get_daemon_address();
|
||||||
|
@ -1056,7 +1058,7 @@ bool WalletImpl::connectToDaemon()
|
||||||
Wallet::ConnectionStatus WalletImpl::connected() const
|
Wallet::ConnectionStatus WalletImpl::connected() const
|
||||||
{
|
{
|
||||||
uint32_t version = 0;
|
uint32_t version = 0;
|
||||||
m_is_connected = m_wallet->check_connection(&version);
|
m_is_connected = m_wallet->check_connection(&version, DEFAULT_CONNECTION_TIMEOUT_MILLIS);
|
||||||
if (!m_is_connected)
|
if (!m_is_connected)
|
||||||
return Wallet::ConnectionStatus_Disconnected;
|
return Wallet::ConnectionStatus_Disconnected;
|
||||||
if ((version >> 16) != CORE_RPC_VERSION_MAJOR)
|
if ((version >> 16) != CORE_RPC_VERSION_MAJOR)
|
||||||
|
|
|
@ -2234,7 +2234,7 @@ bool wallet2::prepare_file_names(const std::string& file_path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool wallet2::check_connection(uint32_t *version)
|
bool wallet2::check_connection(uint32_t *version, uint32_t timeout)
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
|
boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
|
||||||
|
|
||||||
|
@ -2248,7 +2248,7 @@ bool wallet2::check_connection(uint32_t *version)
|
||||||
u.port = m_testnet ? config::testnet::RPC_DEFAULT_PORT : config::RPC_DEFAULT_PORT;
|
u.port = m_testnet ? config::testnet::RPC_DEFAULT_PORT : config::RPC_DEFAULT_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_http_client.connect(u.host, std::to_string(u.port), 10000))
|
if (!m_http_client.connect(u.host, std::to_string(u.port), timeout))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,7 +402,7 @@ namespace tools
|
||||||
std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
||||||
std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
||||||
std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon);
|
std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon);
|
||||||
bool check_connection(uint32_t *version = NULL);
|
bool check_connection(uint32_t *version = NULL, uint32_t timeout = 200000);
|
||||||
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
|
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
|
||||||
void get_payments(const crypto::hash& payment_id, std::list<wallet2::payment_details>& payments, uint64_t min_height = 0) const;
|
void get_payments(const crypto::hash& payment_id, std::list<wallet2::payment_details>& payments, uint64_t min_height = 0) const;
|
||||||
void get_payments(std::list<std::pair<crypto::hash,wallet2::payment_details>>& payments, uint64_t min_height, uint64_t max_height = (uint64_t)-1) const;
|
void get_payments(std::list<std::pair<crypto::hash,wallet2::payment_details>>& payments, uint64_t min_height, uint64_t max_height = (uint64_t)-1) const;
|
||||||
|
|
Loading…
Reference in a new issue