mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-28 03:57:31 -03:00
gui: use the stored CSubNet entry when unbanning
The previous code visualized the `CSubNet` object as string, then parsed that string back to `CSubNet`. This is sub-optimal given that the original `CSubNet` object can be used directly instead. This avoids calling `LookupSubNet()` from the GUI. Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
This commit is contained in:
parent
40c6c85c05
commit
a981af4e6f
3 changed files with 15 additions and 12 deletions
|
@ -178,3 +178,9 @@ bool BanTableModel::shouldShow()
|
||||||
{
|
{
|
||||||
return priv->size() > 0;
|
return priv->size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BanTableModel::unban(const QModelIndex& index)
|
||||||
|
{
|
||||||
|
CCombinedBan* ban{static_cast<CCombinedBan*>(index.internalPointer())};
|
||||||
|
return ban != nullptr && m_node.unban(ban->subnet);
|
||||||
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
|
|
||||||
bool shouldShow();
|
bool shouldShow();
|
||||||
|
|
||||||
|
bool unban(const QModelIndex& index);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
#include <netbase.h>
|
|
||||||
#include <qt/bantablemodel.h>
|
#include <qt/bantablemodel.h>
|
||||||
#include <qt/clientmodel.h>
|
#include <qt/clientmodel.h>
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
@ -1308,17 +1307,13 @@ void RPCConsole::unbanSelectedNode()
|
||||||
|
|
||||||
// Get selected ban addresses
|
// Get selected ban addresses
|
||||||
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->banlistWidget, BanTableModel::Address);
|
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->banlistWidget, BanTableModel::Address);
|
||||||
for(int i = 0; i < nodes.count(); i++)
|
BanTableModel* ban_table_model{clientModel->getBanTableModel()};
|
||||||
{
|
bool unbanned{false};
|
||||||
// Get currently selected ban address
|
for (const auto& node_index : nodes) {
|
||||||
QString strNode = nodes.at(i).data().toString();
|
unbanned |= ban_table_model->unban(node_index);
|
||||||
CSubNet possibleSubnet;
|
|
||||||
|
|
||||||
LookupSubNet(strNode.toStdString(), possibleSubnet);
|
|
||||||
if (possibleSubnet.IsValid() && m_node.unban(possibleSubnet))
|
|
||||||
{
|
|
||||||
clientModel->getBanTableModel()->refresh();
|
|
||||||
}
|
}
|
||||||
|
if (unbanned) {
|
||||||
|
ban_table_model->refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue