From 31bcd8e69ded6ea8c4f23c09670cf554aff94ce9 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 30 Jan 2020 18:13:50 -0500 Subject: [PATCH] ignore block notifications before sync start height, irrelevant to clients --- src/wallet/monero_wallet_core.cpp | 15 ++++++++------- src/wallet/monero_wallet_keys.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wallet/monero_wallet_core.cpp b/src/wallet/monero_wallet_core.cpp index e1b7074..002702e 100644 --- a/src/wallet/monero_wallet_core.cpp +++ b/src/wallet/monero_wallet_core.cpp @@ -692,19 +692,20 @@ namespace monero { void on_new_block(uint64_t height, const cryptonote::block& cn_block) { + // ignore notifications before sync start height, irrelevant to clients + if (m_sync_start_height == boost::none || height < *m_sync_start_height) return; + // notify listeners of block for (monero_wallet_listener* listener : m_wallet.get_listeners()) { listener->on_new_block(height); } // notify listeners of sync progress - if (m_sync_start_height != boost::none && height >= *m_sync_start_height) { - if (height >= *m_sync_end_height) m_sync_end_height = height + 1; // increase end height if necessary - double percent_done = (double) (height - *m_sync_start_height + 1) / (double) (*m_sync_end_height - *m_sync_start_height); - string message = string("Synchronizing"); - for (monero_wallet_listener* listener : m_wallet.get_listeners()) { - listener->on_sync_progress(height, *m_sync_start_height, *m_sync_end_height, percent_done, message); - } + if (height >= *m_sync_end_height) m_sync_end_height = height + 1; // increase end height if necessary + double percent_done = (double) (height - *m_sync_start_height + 1) / (double) (*m_sync_end_height - *m_sync_start_height); + string message = string("Synchronizing"); + for (monero_wallet_listener* listener : m_wallet.get_listeners()) { + listener->on_sync_progress(height, *m_sync_start_height, *m_sync_end_height, percent_done, message); } } diff --git a/src/wallet/monero_wallet_keys.h b/src/wallet/monero_wallet_keys.h index 2b57c82..b3484e6 100644 --- a/src/wallet/monero_wallet_keys.h +++ b/src/wallet/monero_wallet_keys.h @@ -64,7 +64,7 @@ using namespace monero; namespace monero { /** - * Monero wallet implementation to provide basic offline key management. + * Implements a Monero wallet to provide basic key management. */ class monero_wallet_keys : public monero_wallet {