Add NotifyMasternodeListChanged signal to CClientUIInterface (#2880)

And use it instead of BlockTipChanged for mn list changes.
This commit is contained in:
UdjinM6 2019-04-25 18:38:49 +03:00 committed by GitHub
parent 19a9e2f4cc
commit dcdb9dba12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -504,6 +504,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();
}
const auto& consensusParams = Params().GetConsensus();
@ -549,6 +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();
}
const auto& consensusParams = Params().GetConsensus();

View File

@ -351,11 +351,15 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
Q_ARG(bool, fHeader));
nLastUpdateNotification = now;
}
}
static void NotifyMasternodeListChanged(ClientModel *clientmodel)
{
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 (!initialSync || now - nLastMasternodeUpdateNotification > MODEL_UPDATE_DELAY*4*5) {
if (masternodeSync.IsBlockchainSynced() || now - nLastMasternodeUpdateNotification > MODEL_UPDATE_DELAY*4*5) {
clientmodel->refreshMasternodeList();
nLastMasternodeUpdateNotification = now;
}
@ -377,6 +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.NotifyAdditionalDataSyncProgressChanged.connect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
}
@ -390,5 +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.NotifyAdditionalDataSyncProgressChanged.disconnect(boost::bind(NotifyAdditionalDataSyncProgressChanged, this, _1));
}

View File

@ -110,6 +110,9 @@ public:
/** Best header has changed */
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip;
/** Masternode list has changed */
boost::signals2::signal<void (void)> NotifyMasternodeListChanged;
/** Additional data sync progress changed */
boost::signals2::signal<void (double nSyncProgress)> NotifyAdditionalDataSyncProgressChanged;