qt: Revamp ClientModel code to handle BannedListChanged core signal

No behavior change.
This commit is contained in:
Hennadii Stepanov 2022-04-10 18:17:22 +02:00
parent 36b12af7ee
commit 48f6d39659
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 6 additions and 16 deletions

View file

@ -24,6 +24,7 @@
#include <functional> #include <functional>
#include <QDebug> #include <QDebug>
#include <QMetaObject>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
@ -215,19 +216,7 @@ QString ClientModel::blocksDir() const
return GUIUtil::PathToQString(gArgs.GetBlocksDirPath()); return GUIUtil::PathToQString(gArgs.GetBlocksDirPath());
} }
void ClientModel::updateBanlist()
{
banTableModel->refresh();
}
// Handlers for core signals // Handlers for core signals
static void BannedListChanged(ClientModel *clientmodel)
{
qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__);
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection);
assert(invoked);
}
static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, interfaces::BlockTip tip, double verificationProgress, bool fHeader) static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, interfaces::BlockTip tip, double verificationProgress, bool fHeader)
{ {
if (fHeader) { if (fHeader) {
@ -277,7 +266,11 @@ void ClientModel::subscribeToCoreSignals()
qDebug() << "ClientModel: NotifyAlertChanged"; qDebug() << "ClientModel: NotifyAlertChanged";
Q_EMIT alertsChanged(getStatusBarWarnings()); Q_EMIT alertsChanged(getStatusBarWarnings());
}); });
m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this)); m_handler_banned_list_changed = m_node.handleBannedListChanged(
[this]() {
qDebug() << "ClienModel: Requesting update for peer banlist";
QMetaObject::invokeMethod(banTableModel, [this] { banTableModel->refresh(); });
});
m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, false)); m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, false));
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, true)); m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, true));
} }

View file

@ -120,9 +120,6 @@ Q_SIGNALS:
// Show progress dialog e.g. for verifychain // Show progress dialog e.g. for verifychain
void showProgress(const QString &title, int nProgress); void showProgress(const QString &title, int nProgress);
public Q_SLOTS:
void updateBanlist();
}; };
#endif // BITCOIN_QT_CLIENTMODEL_H #endif // BITCOIN_QT_CLIENTMODEL_H