xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
app
misc
detail
setup_HashRouter.cpp
1
#include <xrpld/app/misc/setup_HashRouter.h>
2
3
#include <xrpld/core/Config.h>
4
5
#include <xrpl/basics/contract.h>
6
#include <xrpl/config/BasicConfig.h>
7
#include <xrpl/config/Constants.h>
8
#include <xrpl/core/HashRouter.h>
9
10
#include <
chrono
>
11
#include <
cstdint
>
12
#include <
stdexcept
>
13
14
namespace
xrpl
{
15
16
HashRouter::Setup
17
setupHashRouter
(
Config
const
& config)
18
{
19
using namespace
std::chrono
;
20
21
HashRouter::Setup
setup;
22
auto
const
& section = config.
section
(
Sections::kHashrouter
);
23
24
std::int32_t
tmp{};
25
26
if
(
set
(tmp,
Keys::kHoldTime
, section))
27
{
28
if
(tmp < 12)
29
{
30
Throw<std::runtime_error>
(
31
"HashRouter hold time must be at least 12 seconds (the "
32
"approximate validation time for three ledgers)."
);
33
}
34
setup.
holdTime
=
seconds
(tmp);
35
}
36
if
(
set
(tmp,
Keys::kRelayTime
, section))
37
{
38
if
(tmp < 8)
39
{
40
Throw<std::runtime_error>
(
41
"HashRouter relay time must be at least 8 seconds (the "
42
"approximate validation time for two ledgers)."
);
43
}
44
setup.
relayTime
=
seconds
(tmp);
45
}
46
if
(setup.
relayTime
> setup.
holdTime
)
47
{
48
Throw<std::runtime_error>
(
"HashRouter relay time must be less than or equal to hold time"
);
49
}
50
51
return
setup;
52
}
53
54
}
// namespace xrpl
chrono
xrpl::BasicConfig::section
Section & section(std::string const &name)
Returns the section with the given name.
Definition
BasicConfig.cpp:121
xrpl::Config
Definition
src/xrpld/core/Config.h:89
cstdint
std::chrono::seconds
std::int32_t
std::chrono
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::set
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Definition
BasicConfig.h:320
xrpl::setupHashRouter
HashRouter::Setup setupHashRouter(Config const &config)
Create HashRouter setup from configuration.
Definition
setup_HashRouter.cpp:17
xrpl::Throw
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition
contract.h:52
stdexcept
xrpl::HashRouter::Setup
Structure used to customize HashRouter behavior.
Definition
HashRouter.h:104
xrpl::HashRouter::Setup::relayTime
Seconds relayTime
Amount of time required before a relayed item will be relayed again.
Definition
HashRouter.h:120
xrpl::HashRouter::Setup::holdTime
Seconds holdTime
Expiration time for a hash entry.
Definition
HashRouter.h:115
xrpl::Keys::kRelayTime
static constexpr auto kRelayTime
Definition
Constants.h:151
xrpl::Keys::kHoldTime
static constexpr auto kHoldTime
Definition
Constants.h:113
xrpl::Sections::kHashrouter
static constexpr auto kHashrouter
Definition
Constants.h:19
Generated by
1.17.0