1
mirror of https://github.com/bitcoin/bitcoin synced 2024-09-28 15:42:24 +02:00

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 <QDebug>
#include <QMetaObject>
#include <QThread>
#include <QTimer>
@ -215,19 +216,7 @@ QString ClientModel::blocksDir() const
return GUIUtil::PathToQString(gArgs.GetBlocksDirPath());
}
void ClientModel::updateBanlist()
{
banTableModel->refresh();
}
// 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)
{
if (fHeader) {
@ -277,7 +266,11 @@ void ClientModel::subscribeToCoreSignals()
qDebug() << "ClientModel: NotifyAlertChanged";
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_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
void showProgress(const QString &title, int nProgress);
public Q_SLOTS:
void updateBanlist();
};
#endif // BITCOIN_QT_CLIENTMODEL_H