rippled
ripple
peerfinder
impl
peerfinder/impl/Tuning.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_PEERFINDER_TUNING_H_INCLUDED
21
#define RIPPLE_PEERFINDER_TUNING_H_INCLUDED
22
23
#include <
array
>
24
25
namespace
ripple
{
26
namespace
PeerFinder {
27
30
namespace
Tuning {
31
32
enum
{
33
//---------------------------------------------------------
34
//
35
// Automatic Connection Policy
36
//
37
//---------------------------------------------------------
38
40
secondsPerConnect
= 10
41
43
,
44
maxConnectAttempts
= 20
45
51
,
52
outPercent
= 15
53
58
,
59
minOutCount
= 10
60
62
,
63
defaultMaxPeers
= 21
64
69
,
70
maxRedirects
= 30
71
};
72
73
//------------------------------------------------------------------------------
74
//
75
// Fixed
76
//
77
//------------------------------------------------------------------------------
78
79
static
std::array<int, 10>
const
connectionBackoff
{
80
{1, 1, 2, 3, 5, 8, 13, 21, 34, 55}};
81
82
//------------------------------------------------------------------------------
83
//
84
// Bootcache
85
//
86
//------------------------------------------------------------------------------
87
88
enum
{
89
// Threshold of cache entries above which we trim.
90
bootcacheSize
= 1000
91
92
// The percentage of addresses we prune when we trim the cache.
93
,
94
bootcachePrunePercent
= 10
95
};
96
97
// The cool down wait between database updates
98
// Ideally this should be larger than the time it takes a full
99
// peer to send us a set of addresses and then disconnect.
100
//
101
static
std::chrono::seconds
const
bootcacheCooldownTime
(60);
102
103
//------------------------------------------------------------------------------
104
//
105
// Livecache
106
//
107
//------------------------------------------------------------------------------
108
109
// Drop incoming messages with hops greater than this number
110
std::uint32_t
constexpr
maxHops
= 6;
111
112
// How many Endpoint to send in each mtENDPOINTS
113
std::uint32_t
constexpr
numberOfEndpoints
= 2 *
maxHops
;
114
115
// The most Endpoint we will accept in mtENDPOINTS
116
std::uint32_t
constexpr
numberOfEndpointsMax
=
117
std::max<decltype(numberOfEndpoints)>(
numberOfEndpoints
* 2, 64);
118
119
// Number of addresses we provide when redirecting.
120
std::uint32_t
constexpr
redirectEndpointCount
= 10;
121
122
// How often we send or accept mtENDPOINTS messages per peer
123
// (we use a prime number of purpose)
124
std::chrono::seconds
constexpr
secondsPerMessage
(151);
125
126
// How long an Endpoint will stay in the cache
127
// This should be a small multiple of the broadcast frequency
128
std::chrono::seconds
constexpr
liveCacheSecondsToLive
(30);
129
130
// How much time to wait before trying an outgoing address again.
131
// Note that we ignore the port for purposes of comparison.
132
std::chrono::seconds
constexpr
recentAttemptDuration
(60);
133
134
}
// namespace Tuning
137
}
// namespace PeerFinder
138
}
// namespace ripple
139
140
#endif
ripple::PeerFinder::Tuning::redirectEndpointCount
constexpr std::uint32_t redirectEndpointCount
Definition:
peerfinder/impl/Tuning.h:120
ripple::PeerFinder::Tuning::defaultMaxPeers
@ defaultMaxPeers
Definition:
peerfinder/impl/Tuning.h:63
ripple::PeerFinder::Tuning::bootcacheCooldownTime
static const std::chrono::seconds bootcacheCooldownTime(60)
ripple::PeerFinder::Tuning::maxRedirects
@ maxRedirects
Definition:
peerfinder/impl/Tuning.h:70
ripple::PeerFinder::Tuning::bootcacheSize
@ bootcacheSize
Definition:
peerfinder/impl/Tuning.h:90
ripple::PeerFinder::Tuning::secondsPerMessage
constexpr std::chrono::seconds secondsPerMessage(151)
std::chrono::seconds
ripple::PeerFinder::Tuning::numberOfEndpointsMax
constexpr std::uint32_t numberOfEndpointsMax
Definition:
peerfinder/impl/Tuning.h:116
ripple::PeerFinder::Tuning::liveCacheSecondsToLive
constexpr std::chrono::seconds liveCacheSecondsToLive(30)
ripple::PeerFinder::Tuning::maxConnectAttempts
@ maxConnectAttempts
Definition:
peerfinder/impl/Tuning.h:44
ripple::PeerFinder::Tuning::connectionBackoff
static const std::array< int, 10 > connectionBackoff
Definition:
peerfinder/impl/Tuning.h:79
array
ripple::PeerFinder::Tuning::outPercent
@ outPercent
Definition:
peerfinder/impl/Tuning.h:52
std::uint32_t
ripple::PeerFinder::Tuning::recentAttemptDuration
constexpr std::chrono::seconds recentAttemptDuration(60)
ripple::PeerFinder::Tuning::minOutCount
@ minOutCount
Definition:
peerfinder/impl/Tuning.h:59
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::PeerFinder::Tuning::bootcachePrunePercent
@ bootcachePrunePercent
Definition:
peerfinder/impl/Tuning.h:94
ripple::PeerFinder::Tuning::secondsPerConnect
@ secondsPerConnect
Time to wait between making batches of connection attempts.
Definition:
peerfinder/impl/Tuning.h:40
ripple::PeerFinder::Tuning::maxHops
constexpr std::uint32_t maxHops
Definition:
peerfinder/impl/Tuning.h:110
ripple::PeerFinder::Tuning::numberOfEndpoints
constexpr std::uint32_t numberOfEndpoints
Definition:
peerfinder/impl/Tuning.h:113
Generated by
1.8.17