Skip to content

Commit a83b631

Browse files
authored
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 0cbe566 commit a83b631

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
@@ -364,14 +364,14 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
364364
}
365365
}
366366

367-
static void NotifyMasternodeListChanged(ClientModel *clientmodel)
367+
static void NotifyMasternodeListChanged(ClientModel *clientmodel, const CDeterministicMNList& newList)
368368
{
369369
static int64_t nLastMasternodeUpdateNotification = 0;
370370
int64_t now = GetTimeMillis();
371371
// if we are in-sync, update the UI regardless of last update time
372372
// no need to refresh masternode list/stats as often as blocks etc.
373373
if (masternodeSync.IsBlockchainSynced() || now - nLastMasternodeUpdateNotification > MODEL_UPDATE_DELAY*4*5) {
374-
clientmodel->refreshMasternodeList();
374+
clientmodel->setMasternodeList(newList);
375375
nLastMasternodeUpdateNotification = now;
376376
}
377377
}
@@ -392,7 +392,7 @@ void ClientModel::subscribeToCoreSignals()
392392
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this));
393393
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, _1, _2, false));
394394
uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, _1, _2, true));
395-
uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this));
395+
uiInterface.NotifyMasternodeListChanged.connect(boost::bind(NotifyMasternodeListChanged, this, _1));
396396
uiInterface.NotifyAdditionalDataSyncProgressChanged.connect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
397397
}
398398

@@ -406,6 +406,6 @@ void ClientModel::unsubscribeFromCoreSignals()
406406
uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
407407
uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, false));
408408
uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this, _1, _2, true));
409-
uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this));
409+
uiInterface.NotifyMasternodeListChanged.disconnect(boost::bind(NotifyMasternodeListChanged, this, _1));
410410
uiInterface.NotifyAdditionalDataSyncProgressChanged.disconnect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
411411
}

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)