aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2023-03-06 12:49:39 +0100
committerVasil Dimov <vd@FreeBSD.org>2023-03-06 16:06:05 +0100
commita981af4e6fd0047bc3e96468db48dd7820dac808 (patch)
treebc01cd177af39391ad7886849f646276ec8e0df9 /src/qt/rpcconsole.cpp
parent40c6c85c05812ee8bf824b639307b1ac17a001c4 (diff)
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>
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index b46a3c039b..0e712062af 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -11,7 +11,6 @@
#include <chainparams.h>
#include <interfaces/node.h>
-#include <netbase.h>
#include <qt/bantablemodel.h>
#include <qt/clientmodel.h>
#include <qt/guiutil.h>
@@ -1308,17 +1307,13 @@ void RPCConsole::unbanSelectedNode()
// Get selected ban addresses
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->banlistWidget, BanTableModel::Address);
- for(int i = 0; i < nodes.count(); i++)
- {
- // Get currently selected ban address
- QString strNode = nodes.at(i).data().toString();
- CSubNet possibleSubnet;
-
- LookupSubNet(strNode.toStdString(), possibleSubnet);
- if (possibleSubnet.IsValid() && m_node.unban(possibleSubnet))
- {
- clientModel->getBanTableModel()->refresh();
- }
+ BanTableModel* ban_table_model{clientModel->getBanTableModel()};
+ bool unbanned{false};
+ for (const auto& node_index : nodes) {
+ unbanned |= ban_table_model->unban(node_index);
+ }
+ if (unbanned) {
+ ban_table_model->refresh();
}
}