xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
peerfinder
include/xrpl/peerfinder/Config.h
1
#pragma once
2
3
#include <xrpl/beast/utility/PropertyStream.h>
4
#include <xrpl/peerfinder/detail/Tuning.h>
5
6
#include <
cstddef
>
7
#include <
cstdint
>
8
#include <
optional
>
9
#include <
string
>
10
#include <
string_view
>
11
12
namespace
xrpl::peer_finder
{
13
14
struct
PeerLimitConfig
15
{
16
std::optional<std::size_t>
maxPeers
;
17
std::optional<std::size_t>
inPeers
;
18
std::optional<std::size_t>
outPeers
;
19
};
20
24
struct
Config
25
{
32
std::size_t
maxPeers
{
tuning::kDefaultMaxPeers
};
33
39
std::size_t
outPeers
=
calcOutPeers
();
// Note: relies on `maxPeers` being initialized
40
46
std::size_t
inPeers
{0};
47
51
bool
peerPrivate
=
true
;
52
56
bool
wantIncoming
{
true
};
57
61
bool
autoConnect
{
true
};
62
66
std::uint16_t
listeningPort
{0};
67
71
std::string
features
;
72
76
int
ipLimit
{0};
77
81
bool
verifyEndpoints
=
true
;
82
83
//--------------------------------------------------------------------------
84
88
[[nodiscard]]
std::size_t
89
calcOutPeers
()
const
;
90
94
void
95
applyTuning
();
96
100
void
101
onWrite
(
beast::PropertyStream::Map
& map)
const
;
102
106
static
Config
107
makeConfig
(
108
bool
peerPrivate
,
109
bool
standalone,
110
PeerLimitConfig
const
& limits,
111
std::uint16_t
port,
112
bool
validationPublicKey,
113
int
ipLimit
,
114
bool
verifyEndpoints
);
115
119
friend
bool
120
operator==
(
Config
const
& lhs,
Config
const
& rhs) =
default
;
121
};
122
123
//------------------------------------------------------------------------------
124
128
enum class
Result
{
InboundDisabled
,
DuplicatePeer
,
IpLimitExceeded
,
Full
,
Success
};
129
144
inline
std::string_view
145
to_string
(
Result
result)
noexcept
146
{
147
switch
(result)
148
{
149
case
Result::InboundDisabled:
150
return
"inbound disabled"
;
151
case
Result::DuplicatePeer:
152
return
"peer already connected"
;
153
case
Result::IpLimitExceeded:
154
return
"ip limit exceeded"
;
155
case
Result::Full:
156
return
"slots full"
;
157
case
Result::Success:
158
return
"success"
;
159
}
160
161
return
"unknown"
;
162
}
163
164
}
// namespace xrpl::peer_finder
std::string
std::string_view
beast::PropertyStream::Map
Definition
PropertyStream.h:207
cstddef
cstdint
std::uint16_t
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
Definition
include/xrpl/peerfinder/Config.h:12
xrpl::peer_finder::Result
Result
Possible results from activating a slot.
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::Result::IpLimitExceeded
@ IpLimitExceeded
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::Result::Success
@ Success
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::Result::InboundDisabled
@ InboundDisabled
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::Result::Full
@ Full
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::Result::DuplicatePeer
@ DuplicatePeer
Definition
include/xrpl/peerfinder/Config.h:128
xrpl::peer_finder::to_string
std::string_view to_string(Result result) noexcept
Converts a Result enum value to its string representation.
Definition
include/xrpl/peerfinder/Config.h:145
optional
std::size_t
string
string_view
xrpl::peer_finder::Config
PeerFinder configuration settings.
Definition
include/xrpl/peerfinder/Config.h:25
xrpl::peer_finder::Config::outPeers
std::size_t outPeers
The number of automatic outbound connections to maintain.
Definition
include/xrpl/peerfinder/Config.h:39
xrpl::peer_finder::Config::onWrite
void onWrite(beast::PropertyStream::Map &map) const
Write the configuration into a property stream.
Definition
libxrpl/peerfinder/Config.cpp:39
xrpl::peer_finder::Config::wantIncoming
bool wantIncoming
true if we want to accept incoming connections.
Definition
include/xrpl/peerfinder/Config.h:56
xrpl::peer_finder::Config::peerPrivate
bool peerPrivate
true if we want our IP address kept private.
Definition
include/xrpl/peerfinder/Config.h:51
xrpl::peer_finder::Config::listeningPort
std::uint16_t listeningPort
The listening port number.
Definition
include/xrpl/peerfinder/Config.h:66
xrpl::peer_finder::Config::operator==
friend bool operator==(Config const &lhs, Config const &rhs)=default
Compares two configurations for equality field by field.
xrpl::peer_finder::Config::autoConnect
bool autoConnect
true if we want to establish connections automatically
Definition
include/xrpl/peerfinder/Config.h:61
xrpl::peer_finder::Config::applyTuning
void applyTuning()
Adjusts the values so they follow the business rules.
Definition
libxrpl/peerfinder/Config.cpp:20
xrpl::peer_finder::Config::makeConfig
static Config makeConfig(bool peerPrivate, bool standalone, PeerLimitConfig const &limits, std::uint16_t port, bool validationPublicKey, int ipLimit, bool verifyEndpoints)
Make peer_finder::Config from peer limit and server mode parameters.
Definition
libxrpl/peerfinder/Config.cpp:52
xrpl::peer_finder::Config::inPeers
std::size_t inPeers
The number of automatic inbound connections to maintain.
Definition
include/xrpl/peerfinder/Config.h:46
xrpl::peer_finder::Config::maxPeers
std::size_t maxPeers
The largest number of public peer slots to allow.
Definition
include/xrpl/peerfinder/Config.h:32
xrpl::peer_finder::Config::ipLimit
int ipLimit
Limit how many incoming connections we allow per IP.
Definition
include/xrpl/peerfinder/Config.h:76
xrpl::peer_finder::Config::calcOutPeers
std::size_t calcOutPeers() const
Returns a suitable value for outPeers according to the rules.
Definition
libxrpl/peerfinder/Config.cpp:13
xrpl::peer_finder::Config::verifyEndpoints
bool verifyEndpoints
true if we want to verify endpoints in TMEndpoints messages
Definition
include/xrpl/peerfinder/Config.h:81
xrpl::peer_finder::Config::features
std::string features
The set of features we advertise.
Definition
include/xrpl/peerfinder/Config.h:71
xrpl::peer_finder::PeerLimitConfig
Definition
include/xrpl/peerfinder/Config.h:15
xrpl::peer_finder::PeerLimitConfig::outPeers
std::optional< std::size_t > outPeers
Definition
include/xrpl/peerfinder/Config.h:18
xrpl::peer_finder::PeerLimitConfig::maxPeers
std::optional< std::size_t > maxPeers
Definition
include/xrpl/peerfinder/Config.h:16
xrpl::peer_finder::PeerLimitConfig::inPeers
std::optional< std::size_t > inPeers
Definition
include/xrpl/peerfinder/Config.h:17
Generated by
1.17.0