Browse Source

Banning/unbanning improvements

pull/112/head
fekt 2 years ago
parent
commit
25d3c9dc34
  1. 1
      src/bannedpeerstablemodel.cpp
  2. 20
      src/mainwindow.cpp
  3. 7
      src/mainwindow.ui
  4. 4
      src/peerstablemodel.cpp
  5. 2
      src/txtablemodel.cpp

1
src/bannedpeerstablemodel.cpp

@ -1,5 +1,6 @@
// Copyright 2019-2021 The Hush developers
// Released under the GPLv3
#include "bannedpeerstablemodel.h"
#include "settings.h"
#include "rpc.h"

20
src/mainwindow.cpp

@ -1453,6 +1453,12 @@ void MainWindow::setupPeersTab() {
if(!ip.isEmpty()) {
menu.addAction(tr("Unban this peer"), [=] () {
ui->statusBar->showMessage(tr("Unbanning peer..."));
// Hide single banned peer
ui->bannedPeersTable->hideRow(index.row());
// Call setban
rpc->setban(ip, "remove", [=] (QJsonValue response){
qDebug() << "setban remove " << response;
ui->statusBar->showMessage(tr("Peer unbanned"), 3 * 1000);
@ -1461,6 +1467,14 @@ void MainWindow::setupPeersTab() {
});
menu.addAction(tr("Unban all peers"), [=] () {
ui->statusBar->showMessage(tr("Unbanning all peers..."));
// Hide all banned peers
for (int i=0; i < bannedPeerModel->rowCount(index); i++){
ui->bannedPeersTable->hideRow(i);
}
// Call clearBanned
rpc->clearBanned([=] (QJsonValue response){
qDebug() << "clearBanned " << response;
ui->statusBar->showMessage(tr("All peers unbanned"), 3 * 1000);
@ -1525,6 +1539,12 @@ void MainWindow::setupPeersTab() {
}
menu.addAction(tr("Ban this peer"), [=] () {
ui->statusBar->showMessage(tr("Banning peer..."));
// Hide single peer
ui->peersTable->hideRow(index.row());
// Call setban
rpc->setban(ip, "add", [=] (QJsonValue response){
qDebug() << "setban add " << response;
ui->statusBar->showMessage(tr("Peer banned"), 3 * 1000);

7
src/mainwindow.ui

@ -22,7 +22,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -222,7 +222,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<widget class="QGroupBox" name="addressBalances">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -250,6 +250,9 @@
</property>
<item>
<widget class="QTableView" name="balancesTable">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>

4
src/peerstablemodel.cpp

@ -1,6 +1,6 @@
// Copyright 2019-2021 The Hush developers
// Released under the GPLv3
#include "txtablemodel.h"
#include "peerstablemodel.h"
#include "settings.h"
#include "rpc.h"
@ -112,7 +112,7 @@ int PeersTableModel::columnCount(const QModelIndex&) const
// If the memo is a Payment URI, then show a payment request icon
if (dat.memo.startsWith("hush:")) {
QIcon icon(":/icons/res/paymentreq.gif");
return QVariant(icon.pixmap(16, 16));
return QVariant(icon.pixmap(16, 16));listtra
} else {
// Return the info pixmap to indicate memo
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);

2
src/txtablemodel.cpp

@ -72,7 +72,7 @@ bool TxTableModel::exportToCsv(QString fileName) const {
return true;
}
void TxTableModel::updateAllData() {
void TxTableModel::updateAllData() {
auto newmodeldata = new QList<TransactionItem>();
if (tTrans != nullptr) std::copy( tTrans->begin(), tTrans->end(), std::back_inserter(*newmodeldata));

Loading…
Cancel
Save