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
This commit is contained in:
UdjinM6 2019-06-08 14:17:56 +03:00 committed by Alexander Block
parent 05adda99fe
commit c5415e746a
3 changed files with 7 additions and 7 deletions

View File

@ -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();

View File

@ -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));
}

View File

@ -111,7 +111,7 @@ public:
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip;
/** Masternode list has changed */
boost::signals2::signal<void (void)> NotifyMasternodeListChanged;
boost::signals2::signal<void (const CDeterministicMNList&)> NotifyMasternodeListChanged;
/** Additional data sync progress changed */
boost::signals2::signal<void (double nSyncProgress)> NotifyAdditionalDataSyncProgressChanged;