Keep and report some extra peer information.

This commit is contained in:
JoelKatz
2012-06-30 19:07:08 -07:00
parent c90f834f7f
commit 51100a3b30

View File

@@ -870,7 +870,15 @@ void Peer::recvStatus(newcoin::TMStatusChange& packet)
Log(lsTRACE) << "Received status change from peer " << getIP();
if (!packet.has_networktime())
packet.set_networktime(theApp->getOPs().getNetworkTimeNC());
mLastStatus = packet;
if (!mLastStatus.has_newstatus() || packet.has_newstatus())
mLastStatus = packet;
else
{ // preserve old status
newcoin::NodeStatus status = mLastStatus.newstatus();
mLastStatus = packet;
packet.set_newstatus(status);
}
if (packet.newevent() == newcoin::neLOST_SYNC)
{
@@ -1165,6 +1173,23 @@ Json::Value Peer::getJson()
(mHello.protoversion() != MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR)))
ret["protocol"] = boost::lexical_cast<std::string>(GET_VERSION_MAJOR(mHello.protoversion())) + "." +
boost::lexical_cast<std::string>(GET_VERSION_MINOR(mHello.protoversion()));
if (!!mClosedLedgerHash)
ret["ledger"] = mClosedLedgerHash.GetHex();
if (mLastStatus.has_newstatus())
{
switch (mLastStatus.newstatus())
{
case newcoin::nsCONNECTING: ret["status"] = "connecting"; break;
case newcoin::nsCONNECTED: ret["status"] = "connected"; break;
case newcoin::nsMONITORING: ret["status"] = "monitoring"; break;
case newcoin::nsVALIDATING: ret["status"] = "validating"; break;
case newcoin::nsSHUTTING: ret["status"] = "shutting"; break;
default: Log(lsWARNING) << "Peer has unknown status: " << mLastStatus.newstatus();
}
}
/*
if (!mIpPort.first.empty())
{