Skip to content

Commit

Permalink
[Qt] adapt QT ban option to banlist.dat changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Sep 16, 2015
1 parent 65abe91 commit b1189cf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/qt/bantablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan
case BanTableModel::Address:
return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0;
case BanTableModel::Bantime:
return pLeft->bantil < pRight->bantil;
return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil;
}

return false;
Expand All @@ -47,18 +47,18 @@ class BanTablePriv
/** Pull a full list of banned nodes from CNode into our cache */
void refreshBanlist()
{
std::map<CSubNet, int64_t> banMap;
banmap_t banMap;
CNode::GetBanned(banMap);

cachedBanlist.clear();
#if QT_VERSION >= 0x040700
cachedBanlist.reserve(banMap.size());
#endif
foreach (const PAIRTYPE(CSubNet, int64_t)& banentry, banMap)
foreach (const PAIRTYPE(CSubNet, CBanEntry)& banentry, banMap)
{
CCombinedBan banEntry;
banEntry.subnet = banentry.first;
banEntry.bantil = banentry.second;
banEntry.banEntry = banentry.second;
cachedBanlist.append(banEntry);
}

Expand Down Expand Up @@ -120,7 +120,7 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const
return QString::fromStdString(rec->subnet.ToString());
case Bantime:
QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
date = date.addSecs(rec->bantil);
date = date.addSecs(rec->banEntry.nBanUntil);
return date.toString(Qt::SystemLocaleLongDate);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bantablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BanTablePriv;

struct CCombinedBan {
CSubNet subnet;
int64_t bantil;
CBanEntry banEntry;
};

class BannedNodeLessThan
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/rpcconsole.ui
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
Expand Down
10 changes: 5 additions & 5 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ void RPCConsole::setClientModel(ClientModel *model)

// create peer table context menu actions
QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
QAction* banAction1h = new QAction(tr("&Ban Node for") + " " + tr("&1 hour"), this);
QAction* banAction24h = new QAction(tr("&Ban Node for") + " " + tr("&24 hours"), this);
QAction* banAction7d = new QAction(tr("&Ban Node for") + " " + tr("&7 days"), this);
QAction* banAction365d = new QAction(tr("&Ban Node for") + " " + tr("&1 year"), this);
QAction* banAction1h = new QAction(tr("Ban Node for") + " " + tr("1 hour"), this);
QAction* banAction24h = new QAction(tr("Ban Node for") + " " + tr("24 hours"), this);
QAction* banAction7d = new QAction(tr("Ban Node for") + " " + tr("7 days"), this);
QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 year"), this);

// create peer table context menu
peersTableContextMenu = new QMenu();
Expand Down Expand Up @@ -806,7 +806,7 @@ void RPCConsole::banSelectedNode(int bantime)
int port = 0;
SplitHostPort(nStr, port, addr);

CNode::Ban(CNetAddr(addr), bantime);
CNode::Ban(CNetAddr(addr), BanReasonManuallyAdded, bantime);
bannedNode->fDisconnect = true;

clearSelectedNode();
Expand Down

0 comments on commit b1189cf

Please sign in to comment.