rippled
ReduceRelayCommon.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright 2020 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_OVERLAY_REDUCERELAYCOMMON_H_INCLUDED
21 #define RIPPLE_OVERLAY_REDUCERELAYCOMMON_H_INCLUDED
22 
23 #include <chrono>
24 
25 namespace ripple {
26 
27 namespace reduce_relay {
28 
29 // Peer's squelch is limited in time to
30 // rand{MIN_UNSQUELCH_EXPIRE, max_squelch},
31 // where max_squelch is
32 // min(max(MAX_UNSQUELCH_EXPIRE_DEFAULT, SQUELCH_PER_PEER * number_of_peers),
33 // MAX_UNSQUELCH_EXPIRE_PEERS)
34 static constexpr auto MIN_UNSQUELCH_EXPIRE = std::chrono::seconds{300};
36 static constexpr auto SQUELCH_PER_PEER = std::chrono::seconds(10);
37 static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS = std::chrono::seconds{3600};
38 // No message received threshold before identifying a peer as idled
39 static constexpr auto IDLED = std::chrono::seconds{8};
40 // Message count threshold to start selecting peers as the source
41 // of messages from the validator. We add peers who reach
42 // MIN_MESSAGE_THRESHOLD to considered pool once MAX_SELECTED_PEERS
43 // reach MAX_MESSAGE_THRESHOLD.
44 static constexpr uint16_t MIN_MESSAGE_THRESHOLD = 9;
45 static constexpr uint16_t MAX_MESSAGE_THRESHOLD = 10;
46 // Max selected peers to choose as the source of messages from validator
47 static constexpr uint16_t MAX_SELECTED_PEERS = 5;
48 // Wait before reduce-relay feature is enabled on boot up to let
49 // the server establish peer connections
50 static constexpr auto WAIT_ON_BOOTUP = std::chrono::minutes{10};
51 // Maximum size of the aggregated transaction hashes per peer.
52 // Once we get to high tps throughput, this cap will prevent
53 // TMTransactions from exceeding the current protocol message
54 // size limit of 64MB.
55 static constexpr std::size_t MAX_TX_QUEUE_SIZE = 10000;
56 
57 } // namespace reduce_relay
58 
59 } // namespace ripple
60 
61 #endif // RIPPLED_REDUCERELAYCOMMON_H_INCLUDED
ripple::reduce_relay::SQUELCH_PER_PEER
static constexpr auto SQUELCH_PER_PEER
Definition: ReduceRelayCommon.h:36
std::chrono::seconds
ripple::reduce_relay::MAX_UNSQUELCH_EXPIRE_DEFAULT
static constexpr auto MAX_UNSQUELCH_EXPIRE_DEFAULT
Definition: ReduceRelayCommon.h:35
ripple::reduce_relay::MAX_MESSAGE_THRESHOLD
static constexpr uint16_t MAX_MESSAGE_THRESHOLD
Definition: ReduceRelayCommon.h:45
chrono
ripple::reduce_relay::IDLED
static constexpr auto IDLED
Definition: ReduceRelayCommon.h:39
ripple::reduce_relay::MIN_MESSAGE_THRESHOLD
static constexpr uint16_t MIN_MESSAGE_THRESHOLD
Definition: ReduceRelayCommon.h:44
ripple::reduce_relay::MIN_UNSQUELCH_EXPIRE
static constexpr auto MIN_UNSQUELCH_EXPIRE
Definition: ReduceRelayCommon.h:34
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::reduce_relay::MAX_TX_QUEUE_SIZE
static constexpr std::size_t MAX_TX_QUEUE_SIZE
Definition: ReduceRelayCommon.h:55
std::size_t
ripple::reduce_relay::MAX_UNSQUELCH_EXPIRE_PEERS
static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS
Definition: ReduceRelayCommon.h:37
ripple::reduce_relay::WAIT_ON_BOOTUP
static constexpr auto WAIT_ON_BOOTUP
Definition: ReduceRelayCommon.h:50
ripple::reduce_relay::MAX_SELECTED_PEERS
static constexpr uint16_t MAX_SELECTED_PEERS
Definition: ReduceRelayCommon.h:47