mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +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:
@@ -465,8 +465,7 @@ Config::loadFromString(std::string const& fileContents)
|
||||
|
||||
if (exists(SECTION_VALIDATION_SEED) && exists(SECTION_VALIDATOR_TOKEN))
|
||||
Throw<std::runtime_error>("Cannot have both [" SECTION_VALIDATION_SEED
|
||||
"] "
|
||||
"and [" SECTION_VALIDATOR_TOKEN
|
||||
"] and [" SECTION_VALIDATOR_TOKEN
|
||||
"] config sections");
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_NETWORK_QUORUM, strTemp, j_))
|
||||
@@ -550,6 +549,51 @@ Config::loadFromString(std::string const& fileContents)
|
||||
SERVER_DOMAIN = strTemp;
|
||||
}
|
||||
|
||||
if (exists(SECTION_OVERLAY))
|
||||
{
|
||||
auto const sec = section(SECTION_OVERLAY);
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
try
|
||||
{
|
||||
if (auto val = sec.get<std::string>("max_unknown_time"))
|
||||
MAX_UNKNOWN_TIME =
|
||||
seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
|
||||
": must be of the form '<number>' representing seconds.");
|
||||
}
|
||||
|
||||
if (MAX_UNKNOWN_TIME < seconds{300} || MAX_UNKNOWN_TIME > seconds{1800})
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value 'max_unknown_time' in " SECTION_OVERLAY
|
||||
": the time must be between 300 and 1800 seconds, inclusive.");
|
||||
|
||||
try
|
||||
{
|
||||
if (auto val = sec.get<std::string>("max_diverged_time"))
|
||||
MAX_DIVERGED_TIME =
|
||||
seconds{beast::lexicalCastThrow<std::uint32_t>(*val)};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
|
||||
": must be of the form '<number>' representing seconds.");
|
||||
}
|
||||
|
||||
if (MAX_DIVERGED_TIME < seconds{60} || MAX_DIVERGED_TIME > seconds{900})
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value 'max_diverged_time' in " SECTION_OVERLAY
|
||||
": the time must be between 60 and 900 seconds, inclusive.");
|
||||
}
|
||||
}
|
||||
|
||||
if (getSingleSection(
|
||||
secConfig, SECTION_AMENDMENT_MAJORITY_TIME, strTemp, j_))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user