Skip to content

Commit c5415e7

Browse files
UdjinM6codablock
authored andcommitted
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
1 parent 05adda9 commit c5415e7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/evo/deterministicmns.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
505505
// Don't hold cs while calling signals
506506
if (diff.HasChanges()) {
507507
GetMainSignals().NotifyMasternodeListChanged(false, oldList, diff);
508-
uiInterface.NotifyMasternodeListChanged();
508+
uiInterface.NotifyMasternodeListChanged(newList);
509509
}
510510

511511
if (nHeight == consensusParams.DIP0003EnforcementHeight) {
@@ -550,7 +550,7 @@ bool CDeterministicMNManager::UndoBlock(const CBlock& block, const CBlockIndex*
550550
if (diff.HasChanges()) {
551551
auto inversedDiff = curList.BuildDiff(prevList);
552552
GetMainSignals().NotifyMasternodeListChanged(true, curList, inversedDiff);
553-
uiInterface.NotifyMasternodeListChanged();
553+
uiInterface.NotifyMasternodeListChanged(prevList);
554554
}
555555

556556
const auto& consensusParams = Params().GetConsensus();

src/qt/clientmodel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,14 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
353353
}
354354
}
355355

356-
static void NotifyMasternodeListChanged(ClientModel *clientmodel)
356+
static void NotifyMasternodeListChanged(ClientModel *clientmodel, const CDeterministicMNList& newList)
357357
{
358358
static int64_t nLastMasternodeUpdateNotification = 0;
359359
int64_t now = GetTimeMillis();
360360
// if we are in-sync, update the UI regardless of last update time
361361
// no need to refresh masternode list/stats as often as blocks etc.
362362
if (masternodeSync.IsBlockchainSynced() || now - nLastMasternodeUpdateNotification > MODEL_UPDATE_DELAY*4*5) {
363-
clientmodel->refreshMasternodeList();
363+
clientmodel->setMasternodeList(newList);
364364
nLastMasternodeUpdateNotification = now;
365365
}
366366
}
@@ -381,7 +381,7 @@ void ClientModel::subscribeToCoreSignals()
381381
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
382382
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false));
383383
uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true));
384-
uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this));
384+
uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this, _1));
385385
uiInterface.NotifyAdditionalDataSyncProgressChanged.connect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
386386
}
387387

@@ -395,6 +395,6 @@ void ClientModel::unsubscribeFromCoreSignals()
395395
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
396396
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false));
397397
uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true));
398-
uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this));
398+
uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this, _1));
399399
uiInterface.NotifyAdditionalDataSyncProgressChanged.disconnect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
400400
}

src/ui_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class CClientUIInterface
111111
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip;
112112

113113
/** Masternode list has changed */
114-
boost::signals2::signal<void (void)> NotifyMasternodeListChanged;
114+
boost::signals2::signal<void (const CDeterministicMNList&)> NotifyMasternodeListChanged;
115115

116116
/** Additional data sync progress changed */
117117
boost::signals2::signal<void (double nSyncProgress)> NotifyAdditionalDataSyncProgressChanged;

0 commit comments

Comments
 (0)