File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed
Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class BanTablePriv
4343 /* * Order (ascending or descending) to sort nodes by */
4444 Qt::SortOrder sortOrder;
4545
46- /* * Pull a full list of banned nodes from CNode into our cache */
46+ /* * Pull a full list of banned nodes from interfaces::Node into our cache */
4747 void refreshBanlist (interfaces::Node& node)
4848 {
4949 banmap_t banMap;
@@ -181,3 +181,9 @@ bool BanTableModel::shouldShow()
181181{
182182 return priv->size () > 0 ;
183183}
184+
185+ bool BanTableModel::unban (const QModelIndex& index)
186+ {
187+ CCombinedBan* ban{static_cast <CCombinedBan*>(index.internalPointer ())};
188+ return ban != nullptr && m_node.unban (ban->subnet );
189+ }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class BannedNodeLessThan
3737};
3838
3939/* *
40- Qt model providing information about connected peers, similar to the
40+ Qt model providing information about banned peers, similar to the
4141 "getpeerinfo" RPC call. Used by the rpc console UI.
4242 */
4343class BanTableModel : public QAbstractTableModel
@@ -68,6 +68,8 @@ class BanTableModel : public QAbstractTableModel
6868
6969 bool shouldShow ();
7070
71+ bool unban (const QModelIndex& index);
72+
7173public Q_SLOTS:
7274 void refresh ();
7375
Original file line number Diff line number Diff line change 1414
1515#include < chainparams.h>
1616#include < interfaces/node.h>
17- #include < netbase.h>
1817#include < node/connection_types.h>
1918#include < qt/bantablemodel.h>
2019#include < qt/clientmodel.h>
@@ -1492,15 +1491,13 @@ void RPCConsole::unbanSelectedNode()
14921491
14931492 // Get selected ban addresses
14941493 QList<QModelIndex> nodes = GUIUtil::getEntryData (ui->banlistWidget , BanTableModel::Address);
1495- for (int i = 0 ; i < nodes.count (); i++)
1496- {
1497- // Get currently selected ban address
1498- QString strNode = nodes.at (i).data ().toString ();
1499- CSubNet possibleSubnet{LookupSubNet (strNode.toStdString ())};
1500- if (possibleSubnet.IsValid () && m_node.unban (possibleSubnet))
1501- {
1502- clientModel->getBanTableModel ()->refresh ();
1503- }
1494+ BanTableModel* ban_table_model{clientModel->getBanTableModel ()};
1495+ bool unbanned{false };
1496+ for (const auto & node_index : nodes) {
1497+ unbanned |= ban_table_model->unban (node_index);
1498+ }
1499+ if (unbanned) {
1500+ ban_table_model->refresh ();
15041501 }
15051502}
15061503
You can’t perform that action at this time.
0 commit comments