aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-10-21 04:13:11 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2013-10-21 04:13:11 -0700
commit0c1222ff848bce72525ddcac3f199de48d407d3c (patch)
treecb38813107fc20a5a7a5749f4812d6ec0bf785d7
parentcc7562b7d2dc4eae6e3ab930a2a37cd3c00aac5d (diff)
parent547c61f8d8b42296fd0a51bad4a2e3a3765aa7fd (diff)
Merge pull request #2929 from Krellan/addrlocal
Additional field to RPC getpeerinfo output: addrlocal
-rw-r--r--src/net.cpp3
-rw-r--r--src/net.h1
-rw-r--r--src/rpcnet.cpp2
3 files changed, 6 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index dd7bf283a9..d223b3999e 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -639,6 +639,9 @@ void CNode::copyStats(CNodeStats &stats)
// Raw ping time is in microseconds, but show it to user as whole seconds (Bitcoin users should be well used to small numbers with many decimal places by now :)
stats.dPingTime = (((double)nPingUsecTime) / 1e6);
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
+
+ // Leave string empty if addrLocal invalid (not filled in yet)
+ stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : "";
}
#undef X
diff --git a/src/net.h b/src/net.h
index 2c2d3a768a..a1dc19df34 100644
--- a/src/net.h
+++ b/src/net.h
@@ -121,6 +121,7 @@ public:
bool fSyncNode;
double dPingTime;
double dPingWait;
+ std::string addrLocal;
};
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 7685dec57b..3c92739852 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -66,6 +66,8 @@ Value getpeerinfo(const Array& params, bool fHelp)
Object obj;
obj.push_back(Pair("addr", stats.addrName));
+ if (!(stats.addrLocal.empty()))
+ obj.push_back(Pair("addrlocal", stats.addrLocal));
obj.push_back(Pair("services", strprintf("%08"PRI64x, stats.nServices)));
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));