xrpld
Loading...
Searching...
No Matches
include/xrpl/peerfinder/detail/Tuning.h
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <chrono>
6#include <cstdint>
7
13
14//---------------------------------------------------------
15//
16// Automatic Connection Policy
17//
18//---------------------------------------------------------
19
23static constexpr auto kSecondsPerConnect = 10;
24
28static constexpr auto kMaxConnectAttempts = 20;
29
36static constexpr auto kOutPercent = 15;
37
43static constexpr auto kMinOutCount = 10;
44
48static constexpr auto kDefaultMaxPeers = 21;
49
55static constexpr auto kMaxRedirects = 30;
56
57//------------------------------------------------------------------------------
58//
59// Fixed
60//
61//------------------------------------------------------------------------------
62
63static 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.
72static constexpr auto kBootcacheSize = 1000;
73
74// The percentage of addresses we prune when we trim the cache.
75static 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//
82
83//------------------------------------------------------------------------------
84//
85// Livecache
86//
87//------------------------------------------------------------------------------
88
89// Drop incoming messages with hops greater than this number
90constexpr std::uint32_t kMaxHops = 6;
91
92// How many Endpoint to send in each mtENDPOINTS
94
95// The most Endpoint we will accept in mtENDPOINTS
98
99// Number of addresses we provide when redirecting.
101
102// How often we send or accept mtENDPOINTS messages per peer
103// (we use a prime number of purpose)
105
106// How long an Endpoint will stay in the cache
107// This should be a small multiple of the broadcast frequency
109
110// How much time to wait before trying an outgoing address again.
111// Note that we ignore the port for purposes of comparison.
113
114} // namespace xrpl::peer_finder::tuning
115
T max(T... args)
static constexpr auto kMaxConnectAttempts
Maximum number of simultaneous connection attempts.
static std::array< int, 10 > const kConnectionBackoff
static constexpr auto kOutPercent
The percentage of total peer slots that are outbound.
constexpr std::chrono::seconds kRecentAttemptDuration(60)
static constexpr auto kSecondsPerConnect
Time to wait between making batches of connection attempts.
static constexpr auto kDefaultMaxPeers
The default value of Config::maxPeers.
constexpr std::chrono::seconds kSecondsPerMessage(151)
static constexpr auto kMinOutCount
A hard minimum on the number of outgoing connections.
static std::chrono::seconds const kBootcacheCooldownTime(60)
static constexpr auto kMaxRedirects
Max redirects we will accept from one connection.
constexpr std::chrono::seconds kLiveCacheSecondsToLive(30)