aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-03-10 09:37:03 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-03-10 10:03:53 +0100
commit218be959031b17b576b2bed44e771f76b1a147de (patch)
treedb5a5d907c0119cec48ae74d0a4cf4fa62db75fa /src/qt
parent6041fc85eafd02ca42d4caccd534e260b65ae194 (diff)
parent8e296230775deade9c63f48e61a1ccc9c7e3f4da (diff)
Merge pull request #3685
8e29623 [Qt] show number of in/out connections in debug console (Philip Kaufmann)
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/clientmodel.cpp13
-rw-r--r--src/qt/clientmodel.h10
-rw-r--r--src/qt/rpcconsole.cpp9
3 files changed, 28 insertions, 4 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index f273b9ea46..cb832fdd42 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -39,9 +39,18 @@ ClientModel::~ClientModel()
unsubscribeFromCoreSignals();
}
-int ClientModel::getNumConnections() const
+int ClientModel::getNumConnections(unsigned int flags) const
{
- return vNodes.size();
+ LOCK(cs_vNodes);
+ if (flags == CONNECTIONS_ALL) // Shortcut if we want total
+ return vNodes.size();
+
+ int nNum = 0;
+ BOOST_FOREACH(CNode* pnode, vNodes)
+ if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
+ nNum++;
+
+ return nNum;
}
int ClientModel::getNumBlocks() const
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index ca735f14ce..f29b695ea1 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -25,6 +25,13 @@ enum BlockSource {
BLOCK_SOURCE_NETWORK
};
+enum NumConnections {
+ CONNECTIONS_NONE = 0,
+ CONNECTIONS_IN = (1U << 0),
+ CONNECTIONS_OUT = (1U << 1),
+ CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT),
+};
+
/** Model for Bitcoin network client. */
class ClientModel : public QObject
{
@@ -36,7 +43,8 @@ public:
OptionsModel *getOptionsModel();
- int getNumConnections() const;
+ //! Return number of connections, default is in- and outbound (total)
+ int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
int getNumBlocks() const;
int getNumBlocksAtStartup();
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index bd29efee86..cb5991adf1 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -349,7 +349,14 @@ void RPCConsole::message(int category, const QString &message, bool html)
void RPCConsole::setNumConnections(int count)
{
- ui->numberOfConnections->setText(QString::number(count));
+ if (!clientModel)
+ return;
+
+ QString connections = QString::number(count) + " (";
+ connections += tr("In:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_IN)) + " / ";
+ connections += tr("Out:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_OUT)) + ")";
+
+ ui->numberOfConnections->setText(connections);
}
void RPCConsole::setNumBlocks(int count, int countOfPeers)