Skip to content

Commit 0c1222f

Browse files
committed
Merge pull request #2929 from Krellan/addrlocal
Additional field to RPC getpeerinfo output: addrlocal
2 parents cc7562b + 547c61f commit 0c1222f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/net.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ void CNode::copyStats(CNodeStats &stats)
639639
// 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 :)
640640
stats.dPingTime = (((double)nPingUsecTime) / 1e6);
641641
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
642+
643+
// Leave string empty if addrLocal invalid (not filled in yet)
644+
stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : "";
642645
}
643646
#undef X
644647

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class CNodeStats
121121
bool fSyncNode;
122122
double dPingTime;
123123
double dPingWait;
124+
std::string addrLocal;
124125
};
125126

126127

src/rpcnet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Value getpeerinfo(const Array& params, bool fHelp)
6666
Object obj;
6767

6868
obj.push_back(Pair("addr", stats.addrName));
69+
if (!(stats.addrLocal.empty()))
70+
obj.push_back(Pair("addrlocal", stats.addrLocal));
6971
obj.push_back(Pair("services", strprintf("%08"PRI64x, stats.nServices)));
7072
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
7173
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));

0 commit comments

Comments
 (0)