rippled
SquelchCommon.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_SQUELCHCOMMON_H_INCLUDED
21 #define RIPPLE_OVERLAY_SQUELCHCOMMON_H_INCLUDED
22 #include <chrono>
23 
24 namespace ripple {
25 
26 namespace squelch {
27 
28 using namespace std::chrono;
29 
30 // Peer's squelch is limited in time to
31 // rand{MIN_UNSQUELCH_EXPIRE, MAX_UNSQUELCH_EXPIRE}
32 static constexpr seconds MIN_UNSQUELCH_EXPIRE = seconds{300};
33 static constexpr seconds MAX_UNSQUELCH_EXPIRE = seconds{600};
34 // No message received threshold before identifying a peer as idled
35 static constexpr seconds IDLED = seconds{8};
36 // Message count threshold to start selecting peers as the source
37 // of messages from the validator. We add peers who reach
38 // MIN_MESSAGE_THRESHOLD to considered pool once MAX_SELECTED_PEERS
39 // reach MAX_MESSAGE_THRESHOLD.
40 static constexpr uint16_t MIN_MESSAGE_THRESHOLD = 9;
41 static constexpr uint16_t MAX_MESSAGE_THRESHOLD = 10;
42 // Max selected peers to choose as the source of messages from validator
43 static constexpr uint16_t MAX_SELECTED_PEERS = 3;
44 // Wait before reduce-relay feature is enabled on boot up to let
45 // the server establish peer connections
46 static constexpr minutes WAIT_ON_BOOTUP = minutes{10};
47 
48 } // namespace squelch
49 
50 } // namespace ripple
51 
52 #endif // RIPPLED_SQUELCHCOMMON_H
ripple::squelch::MAX_UNSQUELCH_EXPIRE
static constexpr seconds MAX_UNSQUELCH_EXPIRE
Definition: SquelchCommon.h:33
ripple::squelch::MAX_SELECTED_PEERS
static constexpr uint16_t MAX_SELECTED_PEERS
Definition: SquelchCommon.h:43
std::chrono::seconds
ripple::squelch::MIN_UNSQUELCH_EXPIRE
static constexpr seconds MIN_UNSQUELCH_EXPIRE
Definition: SquelchCommon.h:32
chrono
ripple::squelch::MAX_MESSAGE_THRESHOLD
static constexpr uint16_t MAX_MESSAGE_THRESHOLD
Definition: SquelchCommon.h:41
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::squelch::IDLED
static constexpr seconds IDLED
Definition: SquelchCommon.h:35
ripple::squelch::WAIT_ON_BOOTUP
static constexpr minutes WAIT_ON_BOOTUP
Definition: SquelchCommon.h:46
ripple::squelch::MIN_MESSAGE_THRESHOLD
static constexpr uint16_t MIN_MESSAGE_THRESHOLD
Definition: SquelchCommon.h:40
std::chrono