From fa23a5006d20bd8f4a6b177ec999bfca4bc2e42c Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 2 Aug 2017 14:44:19 +0100 Subject: [PATCH] wallet2: add a is_synced function --- src/wallet/wallet2.cpp | 9 +++++++++ src/wallet/wallet2.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 6b1026a5..bb8cdaf6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5667,6 +5667,15 @@ uint64_t wallet2::get_blockchain_height_by_date(uint16_t year, uint8_t month, ui } } //---------------------------------------------------------------------------------------------------- +bool wallet2::is_synced() const +{ + uint64_t height; + boost::optional result = m_node_rpc_proxy.get_target_height(height); + if (result && *result != CORE_RPC_STATUS_OK) + return false; + return get_blockchain_current_height() >= height; +} +//---------------------------------------------------------------------------------------------------- void wallet2::generate_genesis(cryptonote::block& b) { if (m_testnet) { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index e7692bad..96dea2e4 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -597,6 +597,8 @@ namespace tools 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; + private: /*! * \brief Stores wallet information to wallet file.