net: make Ban/Unban/ClearBan functionality consistent

- Ban/Unban/ClearBan call uiInterface.BannedListChanged() as necessary
- Ban/Unban/ClearBan sync to disk if the operation is user-invoked
- Mark node for disconnection automatically when banning
- Lock cs_vNodes while setting disconnected
- Don't spin in a tight loop while setting disconnected
This commit is contained in:
Cory Fields
2016-04-18 17:02:43 -04:00
parent cca221fd21
commit 8b8f87714d
3 changed files with 33 additions and 26 deletions

View File

@@ -885,15 +885,13 @@ void RPCConsole::banSelectedNode(int bantime)
// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
// Find possible nodes, ban it and clear the selected node
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
if (FindNode(strNode.toStdString())) {
std::string nStr = strNode.toStdString();
std::string addr;
int port = 0;
SplitHostPort(nStr, port, addr);
CNode::Ban(CNetAddr(addr), BanReasonManuallyAdded, bantime);
bannedNode->fDisconnect = true;
DumpBanlist();
clearSelectedNode();
clientModel->getBanTableModel()->refresh();
@@ -912,7 +910,6 @@ void RPCConsole::unbanSelectedNode()
if (possibleSubnet.IsValid())
{
CNode::Unban(possibleSubnet);
DumpBanlist();
clientModel->getBanTableModel()->refresh();
}
}