mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Add cluster status to 'peers' command output.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user