Browse Source

Adding new "addrlocal" field to RPC getpeerinfo.

The existing CNode::addrLocal member is revealed to the user,
as an address string, similar to the existing "addr" field.
Instead of showing garbage or empty string,
it simply will not appear in the output if local address not known yet.
0.10
Josh Lehan 11 years ago
parent
commit
547c61f8d8
  1. 3
      src/net.cpp
  2. 1
      src/net.h
  3. 2
      src/rpcnet.cpp

3
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 :) // 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.dPingTime = (((double)nPingUsecTime) / 1e6);
stats.dPingWait = (((double)nPingUsecWait) / 1e6); stats.dPingWait = (((double)nPingUsecWait) / 1e6);
// Leave string empty if addrLocal invalid (not filled in yet)
stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : "";
} }
#undef X #undef X

1
src/net.h

@ -121,6 +121,7 @@ public:
bool fSyncNode; bool fSyncNode;
double dPingTime; double dPingTime;
double dPingWait; double dPingWait;
std::string addrLocal;
}; };

2
src/rpcnet.cpp

@ -66,6 +66,8 @@ Value getpeerinfo(const Array& params, bool fHelp)
Object obj; Object obj;
obj.push_back(Pair("addr", stats.addrName)); 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("services", strprintf("%08"PRI64x, stats.nServices)));
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend)); obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv)); obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));

Loading…
Cancel
Save