Add cluster status to 'peers' command output.

This commit is contained in:
JoelKatz
2013-07-14 02:51:47 -07:00
parent 1e26703684
commit f67e658bd7
3 changed files with 34 additions and 0 deletions

View File

@@ -803,6 +803,8 @@ Json::Value RPCHandler::doPeers (Json::Value, LoadType* loadType, ScopedLock& Ma
jvResult["peers"] = getApp().getPeers ().getPeersJson ();
getApp().getUNL().addClusterStatus(jvResult);
return jvResult;
}

View File

@@ -371,6 +371,37 @@ public:
//--------------------------------------------------------------------------
void addClusterStatus (Json::Value& obj)
{
boost::recursive_mutex::scoped_lock sl (mUNLLock);
if (m_clusterNodes.size() > 1) // nodes other than us
{
int now = getApp().getOPs().getNetworkTimeNC();
uint32 ref = getApp().getFeeTrack().getLoadBase();
Json::Value& nodes = (obj["cluster"] = Json::objectValue);
for (std::map<RippleAddress, ClusterNodeStatus>::iterator it = m_clusterNodes.begin(),
end = m_clusterNodes.end(); it != end; ++it)
{
if (it->first != getApp().getLocalCredentials().getNodePublic())
{
Json::Value& node = nodes[it->first.humanNodePublic()];
if (!it->second.getName().empty())
node["tag"] = it->second.getName();
if ((it->second.getLoadFee() != ref) && (it->second.getLoadFee() != 0))
node["fee"] = static_cast<double>(it->second.getLoadFee()) / ref;
if (it->second.getReportTime() != 0)
node["age"] = (it->second.getReportTime() >= now) ? 0 : (now - it->second.getReportTime());
}
}
}
}
//--------------------------------------------------------------------------
void nodeBootstrap ()
{
int iDomains = 0;

View File

@@ -48,6 +48,7 @@ public:
virtual bool nodeUpdate (const RippleAddress& naNodePublic, ClusterNodeStatus const& cnsStatus) = 0;
virtual std::map<RippleAddress, ClusterNodeStatus> getClusterStatus () = 0;
virtual uint32 getClusterFee () = 0;
virtual void addClusterStatus (Json::Value&) = 0;
virtual void nodeBootstrap () = 0;
virtual bool nodeLoad (boost::filesystem::path pConfig) = 0;