xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
peerfinder
detail
include/xrpl/peerfinder/detail/Tuning.h
1
#pragma once
2
3
#include <
algorithm
>
4
#include <
array
>
5
#include <
chrono
>
6
#include <
cstdint
>
7
12
namespace
xrpl::peer_finder::tuning
{
13
14
//---------------------------------------------------------
15
//
16
// Automatic Connection Policy
17
//
18
//---------------------------------------------------------
19
23
static
constexpr
auto
kSecondsPerConnect
= 10;
24
28
static
constexpr
auto
kMaxConnectAttempts
= 20;
29
36
static
constexpr
auto
kOutPercent
= 15;
37
43
static
constexpr
auto
kMinOutCount
= 10;
44
48
static
constexpr
auto
kDefaultMaxPeers
= 21;
49
55
static
constexpr
auto
kMaxRedirects
= 30;
56
57
//------------------------------------------------------------------------------
58
//
59
// Fixed
60
//
61
//------------------------------------------------------------------------------
62
63
static
std::array<int, 10>
const
kConnectionBackoff
{{1, 1, 2, 3, 5, 8, 13, 21, 34, 55}};
64
65
//------------------------------------------------------------------------------
66
//
67
// Bootcache
68
//
69
//------------------------------------------------------------------------------
70
71
// Threshold of cache entries above which we trim.
72
static
constexpr
auto
kBootcacheSize
= 1000;
73
74
// The percentage of addresses we prune when we trim the cache.
75
static
constexpr
auto
kBootcachePrunePercent
= 10;
76
77
// The cool down wait between database updates
78
// Ideally this should be larger than the time it takes a full
79
// peer to send us a set of addresses and then disconnect.
80
//
81
static
std::chrono::seconds
const
kBootcacheCooldownTime
(60);
82
83
//------------------------------------------------------------------------------
84
//
85
// Livecache
86
//
87
//------------------------------------------------------------------------------
88
89
// Drop incoming messages with hops greater than this number
90
constexpr
std::uint32_t
kMaxHops
= 6;
91
92
// How many Endpoint to send in each mtENDPOINTS
93
constexpr
std::uint32_t
kNumberOfEndpoints
= 2 *
kMaxHops
;
94
95
// The most Endpoint we will accept in mtENDPOINTS
96
constexpr
std::uint32_t
kNumberOfEndpointsMax
=
97
std::max<decltype(kNumberOfEndpoints)>
(
kNumberOfEndpoints
* 2, 64);
98
99
// Number of addresses we provide when redirecting.
100
constexpr
std::uint32_t
kRedirectEndpointCount
= 10;
101
102
// How often we send or accept mtENDPOINTS messages per peer
103
// (we use a prime number of purpose)
104
constexpr
std::chrono::seconds
kSecondsPerMessage
(151);
105
106
// How long an Endpoint will stay in the cache
107
// This should be a small multiple of the broadcast frequency
108
constexpr
std::chrono::seconds
kLiveCacheSecondsToLive
(30);
109
110
// How much time to wait before trying an outgoing address again.
111
// Note that we ignore the port for purposes of comparison.
112
constexpr
std::chrono::seconds
kRecentAttemptDuration
(60);
113
114
}
// namespace xrpl::peer_finder::tuning
115
algorithm
array
chrono
cstdint
std::chrono::seconds
std::uint32_t
std::max
T max(T... args)
xrpl::peer_finder::tuning
Heuristically tuned constants.
Definition
include/xrpl/peerfinder/detail/Tuning.h:12
xrpl::peer_finder::tuning::kRedirectEndpointCount
constexpr std::uint32_t kRedirectEndpointCount
Definition
include/xrpl/peerfinder/detail/Tuning.h:100
xrpl::peer_finder::tuning::kNumberOfEndpoints
constexpr std::uint32_t kNumberOfEndpoints
Definition
include/xrpl/peerfinder/detail/Tuning.h:93
xrpl::peer_finder::tuning::kMaxConnectAttempts
static constexpr auto kMaxConnectAttempts
Maximum number of simultaneous connection attempts.
Definition
include/xrpl/peerfinder/detail/Tuning.h:28
xrpl::peer_finder::tuning::kConnectionBackoff
static std::array< int, 10 > const kConnectionBackoff
Definition
include/xrpl/peerfinder/detail/Tuning.h:63
xrpl::peer_finder::tuning::kBootcachePrunePercent
static constexpr auto kBootcachePrunePercent
Definition
include/xrpl/peerfinder/detail/Tuning.h:75
xrpl::peer_finder::tuning::kMaxHops
constexpr std::uint32_t kMaxHops
Definition
include/xrpl/peerfinder/detail/Tuning.h:90
xrpl::peer_finder::tuning::kBootcacheSize
static constexpr auto kBootcacheSize
Definition
include/xrpl/peerfinder/detail/Tuning.h:72
xrpl::peer_finder::tuning::kOutPercent
static constexpr auto kOutPercent
The percentage of total peer slots that are outbound.
Definition
include/xrpl/peerfinder/detail/Tuning.h:36
xrpl::peer_finder::tuning::kRecentAttemptDuration
constexpr std::chrono::seconds kRecentAttemptDuration(60)
xrpl::peer_finder::tuning::kSecondsPerConnect
static constexpr auto kSecondsPerConnect
Time to wait between making batches of connection attempts.
Definition
include/xrpl/peerfinder/detail/Tuning.h:23
xrpl::peer_finder::tuning::kDefaultMaxPeers
static constexpr auto kDefaultMaxPeers
The default value of Config::maxPeers.
Definition
include/xrpl/peerfinder/detail/Tuning.h:48
xrpl::peer_finder::tuning::kSecondsPerMessage
constexpr std::chrono::seconds kSecondsPerMessage(151)
xrpl::peer_finder::tuning::kMinOutCount
static constexpr auto kMinOutCount
A hard minimum on the number of outgoing connections.
Definition
include/xrpl/peerfinder/detail/Tuning.h:43
xrpl::peer_finder::tuning::kBootcacheCooldownTime
static std::chrono::seconds const kBootcacheCooldownTime(60)
xrpl::peer_finder::tuning::kMaxRedirects
static constexpr auto kMaxRedirects
Max redirects we will accept from one connection.
Definition
include/xrpl/peerfinder/detail/Tuning.h:55
xrpl::peer_finder::tuning::kNumberOfEndpointsMax
constexpr std::uint32_t kNumberOfEndpointsMax
Definition
include/xrpl/peerfinder/detail/Tuning.h:96
xrpl::peer_finder::tuning::kLiveCacheSecondsToLive
constexpr std::chrono::seconds kLiveCacheSecondsToLive(30)
Generated by
1.17.0