gui: fix ban from qt console

This commit is contained in:
Cory Fields
2016-10-04 19:27:11 -04:00
committed by lateminer
parent 6b4f463267
commit a9357f0c67
3 changed files with 12 additions and 12 deletions

View File

@@ -685,6 +685,7 @@ void CNode::copyStats(CNodeStats &stats)
{
stats.nodeid = this->GetId();
X(nServices);
X(addr);
X(fRelayTxes);
X(nLastSend);
X(nLastRecv);

View File

@@ -213,6 +213,7 @@ public:
double dPingWait;
double dPingMin;
std::string addrLocal;
CAddress addr;
};

View File

@@ -985,20 +985,18 @@ void RPCConsole::banSelectedNode(int bantime)
if (!clientModel)
return;
if(cachedNodeid == -1)
return;
// Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
if(detailNodeRow < 0)
return;
// Find possible nodes, ban it and clear the selected node
if (FindNode(strNode.toStdString())) {
std::string nStr = strNode.toStdString();
std::string addr;
int port = 0;
SplitHostPort(nStr, port, addr);
CNetAddr resolved;
if(!LookupHost(addr.c_str(), resolved, false))
return;
CNode::Ban(resolved, BanReasonManuallyAdded, bantime);
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
if(stats) {
CNode::Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
clearSelectedNode();
clientModel->getBanTableModel()->refresh();
}