From c9a2482c9583842b3ad385943ea97d6b27496e8e Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 28 Oct 2012 19:17:33 -0700 Subject: [PATCH] Add peer count to server_info. --- src/ConnectionPool.cpp | 7 +++++++ src/ConnectionPool.h | 1 + src/NetworkOPs.cpp | 1 + 3 files changed, 9 insertions(+) diff --git a/src/ConnectionPool.cpp b/src/ConnectionPool.cpp index c9e93f3f7c..a6e1a99241 100644 --- a/src/ConnectionPool.cpp +++ b/src/ConnectionPool.cpp @@ -330,6 +330,13 @@ Json::Value ConnectionPool::getPeersJson() return ret; } +int ConnectionPool::getPeerCount() +{ + boost::mutex::scoped_lock sl(mPeerLock); + + return mConnectedMap.size(); +} + std::vector ConnectionPool::getPeerVector() { std::vector ret; diff --git a/src/ConnectionPool.h b/src/ConnectionPool.h index 569a1e4584..1b909f626a 100644 --- a/src/ConnectionPool.h +++ b/src/ConnectionPool.h @@ -83,6 +83,7 @@ public: // As client failed connect and be accepted. void peerClosed(Peer::ref peer, const std::string& strIp, int iPort); + int getPeerCount(); Json::Value getPeersJson(); std::vector getPeerVector(); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index b3ee6079bd..dbeb8fd1d7 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -890,6 +890,7 @@ Json::Value NetworkOPs::getServerInfo() info["networkLedger"] = "waiting"; info["completeLedgers"] = theApp->getMasterLedger().getCompleteLedgers(); + info["peers"] = theApp->getConnectionPool().getPeerCount(); Json::Value lastClose = Json::objectValue; lastClose["proposers"] = theApp->getOPs().getPreviousProposers();