mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Remove direct bitcoin calls from qt/bantablemodel.cpp
This commit is contained in:
parent
e0b66a3b7c
commit
3034a462a5
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <interface/node.h>
|
#include <interface/node.h>
|
||||||
|
|
||||||
|
#include <addrdb.h>
|
||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
@ -105,6 +106,14 @@ class NodeImpl : public Node
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool getBanned(banmap_t& banmap) override
|
||||||
|
{
|
||||||
|
if (g_connman) {
|
||||||
|
g_connman->GetBanned(banmap);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int64_t getTotalBytesRecv() override { return g_connman ? g_connman->GetTotalBytesRecv() : 0; }
|
int64_t getTotalBytesRecv() override { return g_connman ? g_connman->GetTotalBytesRecv() : 0; }
|
||||||
int64_t getTotalBytesSent() override { return g_connman ? g_connman->GetTotalBytesSent() : 0; }
|
int64_t getTotalBytesSent() override { return g_connman ? g_connman->GetTotalBytesSent() : 0; }
|
||||||
size_t getMempoolSize() override { return ::mempool.size(); }
|
size_t getMempoolSize() override { return ::mempool.size(); }
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef BITCOIN_INTERFACE_NODE_H
|
#ifndef BITCOIN_INTERFACE_NODE_H
|
||||||
#define BITCOIN_INTERFACE_NODE_H
|
#define BITCOIN_INTERFACE_NODE_H
|
||||||
|
|
||||||
|
#include <addrdb.h> // For banmap_t
|
||||||
#include <init.h> // For HelpMessageMode
|
#include <init.h> // For HelpMessageMode
|
||||||
#include <net.h> // For CConnman::NumConnections
|
#include <net.h> // For CConnman::NumConnections
|
||||||
#include <netaddress.h> // For Network
|
#include <netaddress.h> // For Network
|
||||||
@ -87,6 +88,9 @@ public:
|
|||||||
using NodesStats = std::vector<std::tuple<CNodeStats, bool, CNodeStateStats>>;
|
using NodesStats = std::vector<std::tuple<CNodeStats, bool, CNodeStateStats>>;
|
||||||
virtual bool getNodesStats(NodesStats& stats) = 0;
|
virtual bool getNodesStats(NodesStats& stats) = 0;
|
||||||
|
|
||||||
|
//! Get ban map entries.
|
||||||
|
virtual bool getBanned(banmap_t& banmap) = 0;
|
||||||
|
|
||||||
//! Get total bytes recv.
|
//! Get total bytes recv.
|
||||||
virtual int64_t getTotalBytesRecv() = 0;
|
virtual int64_t getTotalBytesRecv() = 0;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <qt/guiconstants.h>
|
#include <qt/guiconstants.h>
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
|
||||||
|
#include <interface/node.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <utiltime.h>
|
#include <utiltime.h>
|
||||||
|
|
||||||
@ -45,11 +46,10 @@ public:
|
|||||||
Qt::SortOrder sortOrder;
|
Qt::SortOrder sortOrder;
|
||||||
|
|
||||||
/** Pull a full list of banned nodes from CNode into our cache */
|
/** Pull a full list of banned nodes from CNode into our cache */
|
||||||
void refreshBanlist()
|
void refreshBanlist(interface::Node& node)
|
||||||
{
|
{
|
||||||
banmap_t banMap;
|
banmap_t banMap;
|
||||||
if(g_connman)
|
node.getBanned(banMap);
|
||||||
g_connman->GetBanned(banMap);
|
|
||||||
|
|
||||||
cachedBanlist.clear();
|
cachedBanlist.clear();
|
||||||
#if QT_VERSION >= 0x040700
|
#if QT_VERSION >= 0x040700
|
||||||
@ -82,8 +82,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BanTableModel::BanTableModel(ClientModel *parent) :
|
BanTableModel::BanTableModel(interface::Node& node, ClientModel *parent) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent),
|
||||||
|
m_node(node),
|
||||||
clientModel(parent)
|
clientModel(parent)
|
||||||
{
|
{
|
||||||
columns << tr("IP/Netmask") << tr("Banned Until");
|
columns << tr("IP/Netmask") << tr("Banned Until");
|
||||||
@ -168,7 +169,7 @@ QModelIndex BanTableModel::index(int row, int column, const QModelIndex &parent)
|
|||||||
void BanTableModel::refresh()
|
void BanTableModel::refresh()
|
||||||
{
|
{
|
||||||
Q_EMIT layoutAboutToBeChanged();
|
Q_EMIT layoutAboutToBeChanged();
|
||||||
priv->refreshBanlist();
|
priv->refreshBanlist(m_node);
|
||||||
Q_EMIT layoutChanged();
|
Q_EMIT layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
class ClientModel;
|
class ClientModel;
|
||||||
class BanTablePriv;
|
class BanTablePriv;
|
||||||
|
|
||||||
|
namespace interface {
|
||||||
|
class Node;
|
||||||
|
}
|
||||||
|
|
||||||
struct CCombinedBan {
|
struct CCombinedBan {
|
||||||
CSubNet subnet;
|
CSubNet subnet;
|
||||||
CBanEntry banEntry;
|
CBanEntry banEntry;
|
||||||
@ -39,7 +43,7 @@ class BanTableModel : public QAbstractTableModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BanTableModel(ClientModel *parent = 0);
|
explicit BanTableModel(interface::Node& node, ClientModel *parent = 0);
|
||||||
~BanTableModel();
|
~BanTableModel();
|
||||||
void startAutoRefresh();
|
void startAutoRefresh();
|
||||||
void stopAutoRefresh();
|
void stopAutoRefresh();
|
||||||
@ -65,6 +69,7 @@ public Q_SLOTS:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
interface::Node& m_node;
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
QStringList columns;
|
QStringList columns;
|
||||||
std::unique_ptr<BanTablePriv> priv;
|
std::unique_ptr<BanTablePriv> priv;
|
||||||
|
@ -43,7 +43,7 @@ ClientModel::ClientModel(interface::Node& node, OptionsModel *_optionsModel, QOb
|
|||||||
cachedBestHeaderHeight = -1;
|
cachedBestHeaderHeight = -1;
|
||||||
cachedBestHeaderTime = -1;
|
cachedBestHeaderTime = -1;
|
||||||
peerTableModel = new PeerTableModel(m_node, this);
|
peerTableModel = new PeerTableModel(m_node, this);
|
||||||
banTableModel = new BanTableModel(this);
|
banTableModel = new BanTableModel(m_node, this);
|
||||||
pollTimer = new QTimer(this);
|
pollTimer = new QTimer(this);
|
||||||
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
|
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
|
||||||
pollTimer->start(MODEL_UPDATE_DELAY);
|
pollTimer->start(MODEL_UPDATE_DELAY);
|
||||||
|
Loading…
Reference in New Issue
Block a user