Skip to content

Commit

Permalink
Merge pull request #2929 from Krellan/addrlocal
Browse files Browse the repository at this point in the history
Additional field to RPC getpeerinfo output: addrlocal
  • Loading branch information
laanwj committed Oct 21, 2013
2 parents cc7562b + 547c61f commit 0c1222f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class CNodeStats
bool fSyncNode;
double dPingTime;
double dPingWait;
std::string addrLocal;
};


Expand Down
2 changes: 2 additions & 0 deletions src/rpcnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 0c1222f

Please sign in to comment.