mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve handling of peers that aren't synced:
When evaluating the fitness and usefulness of an outbound peer, the code would incorrectly calculate the amount of time that the peer spent in a non-useful state. This commit, if merged, corrects the calculation and makes the timeout values configurable by server operators. Two new options are introduced in the 'overlay' stanza of the config file. The default values, in seconds, are: [overlay] max_unknown_time = 600 max_diverged_time = 300
This commit is contained in:
@@ -32,17 +32,33 @@ doPeers(RPC::JsonContext& context)
|
||||
{
|
||||
Json::Value jvResult(Json::objectValue);
|
||||
|
||||
jvResult[jss::peers] = context.app.overlay().json();
|
||||
|
||||
// Legacy support
|
||||
if (context.apiVersion == 1)
|
||||
{
|
||||
jvResult[jss::peers] = context.app.overlay().json();
|
||||
for (auto& p : jvResult[jss::peers])
|
||||
{
|
||||
if (p.isMember(jss::track))
|
||||
{
|
||||
auto const s = p[jss::track].asString();
|
||||
|
||||
auto const now = context.app.timeKeeper().now();
|
||||
auto const self = context.app.nodeIdentity().first;
|
||||
if (s == "diverged")
|
||||
p["sanity"] = "insane";
|
||||
else if (s == "unknown")
|
||||
p["sanity"] = "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value& cluster = (jvResult[jss::cluster] = Json::objectValue);
|
||||
std::uint32_t ref = context.app.getFeeTrack().getLoadBase();
|
||||
auto const now = context.app.timeKeeper().now();
|
||||
auto const self = context.app.nodeIdentity().first;
|
||||
|
||||
context.app.cluster().for_each([&cluster, now, ref, &self](
|
||||
ClusterNode const& node) {
|
||||
Json::Value& cluster = (jvResult[jss::cluster] = Json::objectValue);
|
||||
std::uint32_t ref = context.app.getFeeTrack().getLoadBase();
|
||||
|
||||
context.app.cluster().for_each(
|
||||
[&cluster, now, ref, &self](ClusterNode const& node) {
|
||||
if (node.identity() == self)
|
||||
return;
|
||||
|
||||
@@ -60,7 +76,6 @@ doPeers(RPC::JsonContext& context)
|
||||
? 0
|
||||
: (now - node.getReportTime()).count();
|
||||
});
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user