From c5415e746a6d1dc4f6991d1ad9d0aea333eac754 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 8 Jun 2019 14:17:56 +0300 Subject: [PATCH] Fix UI masternode list (#2966) NotifyMasternodeListChanged is called before the tip is updated which means we can't rely on GetListAtChainTip() and have to pass the list into CClientUIInterface --- src/evo/deterministicmns.cpp | 4 ++-- src/qt/clientmodel.cpp | 8 ++++---- src/ui_interface.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index a00341851..0cfaab4e3 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -505,7 +505,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde // Don't hold cs while calling signals if (diff.HasChanges()) { GetMainSignals().NotifyMasternodeListChanged(false, oldList, diff); - uiInterface.NotifyMasternodeListChanged(); + uiInterface.NotifyMasternodeListChanged(newList); } if (nHeight == consensusParams.DIP0003EnforcementHeight) { @@ -550,7 +550,7 @@ bool CDeterministicMNManager::UndoBlock(const CBlock& block, const CBlockIndex* if (diff.HasChanges()) { auto inversedDiff = curList.BuildDiff(prevList); GetMainSignals().NotifyMasternodeListChanged(true, curList, inversedDiff); - uiInterface.NotifyMasternodeListChanged(); + uiInterface.NotifyMasternodeListChanged(prevList); } const auto& consensusParams = Params().GetConsensus(); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 1ba75e691..271e8275e 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -353,14 +353,14 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB } } -static void NotifyMasternodeListChanged(ClientModel *clientmodel) +static void NotifyMasternodeListChanged(ClientModel *clientmodel, const CDeterministicMNList& newList) { static int64_t nLastMasternodeUpdateNotification = 0; int64_t now = GetTimeMillis(); // if we are in-sync, update the UI regardless of last update time // no need to refresh masternode list/stats as often as blocks etc. if (masternodeSync.IsBlockchainSynced() || now - nLastMasternodeUpdateNotification > MODEL_UPDATE_DELAY*4*5) { - clientmodel->refreshMasternodeList(); + clientmodel->setMasternodeList(newList); nLastMasternodeUpdateNotification = now; } } @@ -381,7 +381,7 @@ void ClientModel::subscribeToCoreSignals() uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false)); uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true)); - uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this)); + uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this, _1)); uiInterface.NotifyAdditionalDataSyncProgressChanged.connect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1)); } @@ -395,6 +395,6 @@ void ClientModel::unsubscribeFromCoreSignals() uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this)); uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false)); uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true)); - uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this)); + uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this, _1)); uiInterface.NotifyAdditionalDataSyncProgressChanged.disconnect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1)); } diff --git a/src/ui_interface.h b/src/ui_interface.h index 98c882d63..9d5ad977e 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -111,7 +111,7 @@ public: boost::signals2::signal NotifyHeaderTip; /** Masternode list has changed */ - boost::signals2::signal NotifyMasternodeListChanged; + boost::signals2::signal NotifyMasternodeListChanged; /** Additional data sync progress changed */ boost::signals2::signal NotifyAdditionalDataSyncProgressChanged;