rippled
Loading...
Searching...
No Matches
setup_HashRouter.cpp
1#include <xrpld/app/misc/setup_HashRouter.h>
2#include <xrpld/core/Config.h>
3
4#include <xrpl/basics/BasicConfig.h>
5
6namespace xrpl {
7
8HashRouter::Setup
9setup_HashRouter(Config const& config)
10{
11 using namespace std::chrono;
12
14 auto const& section = config.section("hashrouter");
15
16 std::int32_t tmp{};
17
18 if (set(tmp, "hold_time", section))
19 {
20 if (tmp < 12)
21 Throw<std::runtime_error>(
22 "HashRouter hold time must be at least 12 seconds (the "
23 "approximate validation time for three ledgers).");
24 setup.holdTime = seconds(tmp);
25 }
26 if (set(tmp, "relay_time", section))
27 {
28 if (tmp < 8)
29 Throw<std::runtime_error>(
30 "HashRouter relay time must be at least 8 seconds (the "
31 "approximate validation time for two ledgers).");
32 setup.relayTime = seconds(tmp);
33 }
34 if (setup.relayTime > setup.holdTime)
35 {
36 Throw<std::runtime_error>("HashRouter relay time must be less than or equal to hold time");
37 }
38
39 return setup;
40}
41
42} // namespace xrpl
Section & section(std::string const &name)
Returns the section with the given name.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
HashRouter::Setup setup_HashRouter(Config const &config)
Create HashRouter setup from configuration.
Structure used to customize HashRouter behavior.
Definition HashRouter.h:91
seconds holdTime
Expiration time for a hash entry.
Definition HashRouter.h:99
seconds relayTime
Amount of time required before a relayed item will be relayed again.
Definition HashRouter.h:103