diff options
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bantablemodel.cpp | 3 | ||||
-rw-r--r-- | src/qt/clientmodel.cpp | 26 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 8 | ||||
-rw-r--r-- | src/qt/guiutil.h | 2 | ||||
-rw-r--r-- | src/qt/peertablemodel.cpp | 21 | ||||
-rw-r--r-- | src/qt/peertablemodel.h | 7 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 41 | ||||
-rw-r--r-- | src/qt/walletmodel.cpp | 2 |
8 files changed, 58 insertions, 52 deletions
diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp index d95106b5ac..6e11e23904 100644 --- a/src/qt/bantablemodel.cpp +++ b/src/qt/bantablemodel.cpp @@ -48,7 +48,8 @@ public: void refreshBanlist() { banmap_t banMap; - CNode::GetBanned(banMap); + if(g_connman) + g_connman->GetBanned(banMap); cachedBanlist.clear(); #if QT_VERSION >= 0x040700 diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 14661b857a..83c78850e2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -50,16 +50,18 @@ ClientModel::~ClientModel() int ClientModel::getNumConnections(unsigned int flags) const { - LOCK(cs_vNodes); - if (flags == CONNECTIONS_ALL) // Shortcut if we want total - return vNodes.size(); + CConnman::NumConnections connections = CConnman::CONNECTIONS_NONE; - int nNum = 0; - BOOST_FOREACH(const CNode* pnode, vNodes) - if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT)) - nNum++; + if(flags == CONNECTIONS_IN) + connections = CConnman::CONNECTIONS_IN; + else if (flags == CONNECTIONS_OUT) + connections = CConnman::CONNECTIONS_OUT; + else if (flags == CONNECTIONS_ALL) + connections = CConnman::CONNECTIONS_ALL; - return nNum; + if(g_connman) + return g_connman->GetNodeCount(connections); + return 0; } int ClientModel::getNumBlocks() const @@ -70,12 +72,16 @@ int ClientModel::getNumBlocks() const quint64 ClientModel::getTotalBytesRecv() const { - return CNode::GetTotalBytesRecv(); + if(!g_connman) + return 0; + return g_connman->GetTotalBytesRecv(); } quint64 ClientModel::getTotalBytesSent() const { - return CNode::GetTotalBytesSent(); + if(!g_connman) + return 0; + return g_connman->GetTotalBytesSent(); } QDateTime ClientModel::getLastBlockDate() const diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index c00f5e8591..444e35de8a 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -291,17 +291,17 @@ void copyEntryData(QAbstractItemView *view, int column, int role) } } -QString getEntryData(QAbstractItemView *view, int column, int role) +QVariant getEntryData(QAbstractItemView *view, int column, int role) { if(!view || !view->selectionModel()) - return QString(); + return QVariant(); QModelIndexList selection = view->selectionModel()->selectedRows(column); if(!selection.isEmpty()) { // Return first item - return (selection.at(0).data(role).toString()); + return (selection.at(0).data(role)); } - return QString(); + return QVariant(); } QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 9267e0a6c9..d5a658e7c0 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -70,7 +70,7 @@ namespace GUIUtil @param[in] role Data role to extract from the model @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress */ - QString getEntryData(QAbstractItemView *view, int column, int role); + QVariant getEntryData(QAbstractItemView *view, int column, int role); void setClipboard(const QString& str); diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 84ad0052fd..a820bd791f 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -24,6 +24,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine switch(column) { + case PeerTableModel::NetNodeId: + return pLeft->nodeid < pRight->nodeid; case PeerTableModel::Address: return pLeft->addrName.compare(pRight->addrName) < 0; case PeerTableModel::Subversion: @@ -52,24 +54,21 @@ public: void refreshPeers() { { - TRY_LOCK(cs_vNodes, lockNodes); - if (!lockNodes) - { - // skip the refresh if we can't immediately get the lock - return; - } cachedNodeStats.clear(); + std::vector<CNodeStats> vstats; + if(g_connman) + g_connman->GetNodeStats(vstats); #if QT_VERSION >= 0x040700 - cachedNodeStats.reserve(vNodes.size()); + cachedNodeStats.reserve(vstats.size()); #endif - Q_FOREACH (CNode* pnode, vNodes) + Q_FOREACH (const CNodeStats& nodestats, vstats) { CNodeCombinedStats stats; stats.nodeStateStats.nMisbehavior = 0; stats.nodeStateStats.nSyncHeight = -1; stats.nodeStateStats.nCommonHeight = -1; stats.fNodeStateStatsAvailable = false; - pnode->copyStats(stats.nodeStats); + stats.nodeStats = nodestats; cachedNodeStats.append(stats); } } @@ -114,7 +113,7 @@ PeerTableModel::PeerTableModel(ClientModel *parent) : clientModel(parent), timer(0) { - columns << tr("Node/Service") << tr("User Agent") << tr("Ping Time"); + columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping Time"); priv = new PeerTablePriv(); // default to unsorted priv->sortColumn = -1; @@ -160,6 +159,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const if (role == Qt::DisplayRole) { switch(index.column()) { + case NetNodeId: + return rec->nodeStats.nodeid; case Address: return QString::fromStdString(rec->nodeStats.addrName); case Subversion: diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index a2aaaa5d24..a4f7bbdb3d 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -52,9 +52,10 @@ public: void stopAutoRefresh(); enum ColumnIndex { - Address = 0, - Subversion = 1, - Ping = 2 + NetNodeId = 0, + Address = 1, + Subversion = 2, + Ping = 3 }; /** @name Methods overridden from QAbstractTableModel diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index bcaa9164c9..f35f401d06 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -876,37 +876,34 @@ void RPCConsole::showBanTableContextMenu(const QPoint& point) void RPCConsole::disconnectSelectedNode() { + if(!g_connman) + return; // Get currently selected peer address - QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address); + NodeId id = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::NetNodeId).toInt(); // Find the node, disconnect it and clear the selected node - if (CNode *bannedNode = FindNode(strNode.toStdString())) { - bannedNode->fDisconnect = true; + if(g_connman->DisconnectNode(id)) clearSelectedNode(); - } } void RPCConsole::banSelectedNode(int bantime) { - if (!clientModel) + if (!clientModel || !g_connman) return; // Get currently selected peer address - QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address); + QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString(); // 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); + std::string nStr = strNode.toStdString(); + std::string addr; + int port = 0; + SplitHostPort(nStr, port, addr); - clearSelectedNode(); - clientModel->getBanTableModel()->refresh(); - } + CNetAddr resolved; + if(!LookupHost(addr.c_str(), resolved, false)) + return; + g_connman->Ban(resolved, BanReasonManuallyAdded, bantime); + clearSelectedNode(); + clientModel->getBanTableModel()->refresh(); } void RPCConsole::unbanSelectedNode() @@ -915,13 +912,13 @@ void RPCConsole::unbanSelectedNode() return; // Get currently selected ban address - QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address); + QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address).toString(); CSubNet possibleSubnet; LookupSubNet(strNode.toStdString().c_str(), possibleSubnet); - if (possibleSubnet.IsValid()) + if (possibleSubnet.IsValid() && g_connman) { - CNode::Unban(possibleSubnet); + g_connman->Unban(possibleSubnet); clientModel->getBanTableModel()->refresh(); } } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index ae7efc7a0d..73851e97fc 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -328,7 +328,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran } CReserveKey *keyChange = transaction.getPossibleKeyChange(); - if(!wallet->CommitTransaction(*newTx, *keyChange)) + if(!wallet->CommitTransaction(*newTx, *keyChange, g_connman.get())) return TransactionCommitFailed; CTransaction* t = (CTransaction*)newTx; |