Skip to content

Commit

Permalink
Merge #2852: [GUI] Fix ban actions in peer list
Browse files Browse the repository at this point in the history
a86ab9e Fix GUI banning (Liquid)

Pull request description:

  For quite some time in the PIVX GUI we have the old UX for the peer list, and it has not been functional to ban peers using the context menu.
  See below:
  ![Screenshot 2023-04-17 at 1 40 46 PM](https://user-images.githubusercontent.com/45834289/232580836-d0f39b6e-a258-4347-9245-afeaa197a3de.png)

  Any amount of clicks, it will not ban said peer nor will it update the ban list.

  With this PR it is now working as intended again

  ![Screenshot 2023-04-17 at 1 42 12 PM](https://user-images.githubusercontent.com/45834289/232581174-007668e1-ce65-4ae8-a989-eb916b99b669.png)

  Clicking ban node for X time, will automatically disconnect the peer and update the GUI/ban list

  Changes:

  We now track the nodes address in the NodeStats class, and so now we do not need to resolve the IP but rather pull it from the stats we have access to after syncing the information from the node.

ACKs for top commit:
  Fuzzbawls:
    ACK a86ab9e
  panleone:
    tACK a86ab9e

Tree-SHA512: 1cfb776787fd81f6e3c5230c57db5bdb1919a32455ef6b624f59d8706f39d0b60d21458b986b11e0015804a54793bb664f053cd360d5770997a3dbd139955c0a
  • Loading branch information
Fuzzbawls committed May 3, 2023
2 parents a428bc2 + a86ab9e commit aca81a1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,15 +808,24 @@ void RPCConsole::banSelectedNode(int bantime)
if (!clientModel || !g_connman)
return;

// No node selected exit out
if (cachedNodeid == -1)
return;

// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
// Find possible nodes, ban it and clear the selected node
std::string nStr = strNode.toStdString();
int selectedNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
if (selectedNodeRow < 0)
return;

// Get nodeStats and we will use the addrName string(ip address)
const CNodeCombinedStats* stats = clientModel->getPeerTableModel()->getNodeStats(selectedNodeRow);

std::string nStr = stats->nodeStats.addrName;
std::string addr;
int port = 0;
SplitHostPort(nStr, port, addr);

CNetAddr resolved;

if (!LookupHost(addr.c_str(), resolved, false))
return;
g_connman->Ban(resolved, BanReasonManuallyAdded, bantime);
Expand Down

0 comments on commit aca81a1

Please sign in to comment.