Replaces check for in sync with is close to being synced

The wallet can occassionally become "out of sync" when a new block is
added so it becomes one block behind the chain height. This results in
errors in the wallet which are unnecessary because the user immediately
calls the function after it fails and it will succeed.
This commit is contained in:
Sean Darcy 2020-12-17 09:10:55 +11:00
parent 4befe3f111
commit cbbd1208f9
2 changed files with 10 additions and 1 deletions

View file

@ -8339,7 +8339,7 @@ wallet2::register_service_node_result wallet2::create_register_service_node_tx(c
return result;
}
if (!is_synced())
if (!is_close_to_synced())
{
result.status = register_service_node_result_status::wallet_not_synced;
result.msg = tr("Wallet is not synced. Please synchronise your wallet to the blockchain");
@ -14564,6 +14564,14 @@ bool wallet2::is_synced() const
return get_blockchain_current_height() >= height;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::is_close_to_synced() const
{
uint64_t height;
if (!m_node_rpc_proxy.get_height(height))
return false;
return get_blockchain_current_height() >= height-1;
}
//----------------------------------------------------------------------------------------------------
uint64_t wallet2::get_segregation_fork_height() const
{
if (m_nettype == MAINNET && m_segregation_height > 0)

View file

@ -1214,6 +1214,7 @@ private:
uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
bool is_synced() const;
bool is_close_to_synced() const;
uint64_t get_fee_percent(uint32_t priority, cryptonote::txtype type) const;
cryptonote::byte_and_output_fees get_base_fees() const;