Skip to content

Commit 6def9d8

Browse files
committed
comment
Signed-off-by: turuslan <[email protected]>
1 parent cab1bf2 commit 6def9d8

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

include/libp2p/connection/stream_pair.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ namespace libp2p::basic {
1515
namespace libp2p::connection {
1616
struct Stream;
1717

18+
/**
19+
* Create pair of connected bidirectional read-writers
20+
* implementing `Stream` interface.
21+
*/
1822
std::pair<std::shared_ptr<Stream>, std::shared_ptr<Stream>> streamPair(
1923
std::shared_ptr<basic::Scheduler> post, PeerId peer1, PeerId peer2);
2024
} // namespace libp2p::connection

include/libp2p/protocol/gossip/gossip.hpp

+38
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,60 @@ namespace libp2p::protocol::gossip {
8787
/// Sign published messages
8888
bool sign_messages = false;
8989

90+
/// Number of heartbeats to keep in the `memcache`
9091
size_t history_length{5};
9192

93+
/// Number of past heartbeats to gossip about (default is 3).
9294
size_t history_gossip{3};
9395

96+
/// Time to live for fanout peers (default is 60 seconds).
9497
std::chrono::seconds fanout_ttl{60};
9598

99+
/// Duplicates are prevented by storing message id's of known messages in an
100+
/// LRU time cache. This settings sets the time period that messages are
101+
/// stored in the cache. Duplicates can be received if duplicate messages
102+
/// are sent at a time greater than this setting apart. The default is 1
103+
/// minute.
96104
std::chrono::seconds duplicate_cache_time{60};
97105

106+
/// Controls the backoff time for pruned peers. This is how long
107+
/// a peer must wait before attempting to graft into our mesh again after
108+
/// being pruned. When pruning a peer, we send them our value of
109+
/// `prune_backoff` so they know the minimum time to wait. Peers running
110+
/// older versions may not send a backoff time, so if we receive a prune
111+
/// message without one, we will wait at least `prune_backoff` before
112+
/// attempting to re-graft. The default is one minute.
98113
std::chrono::seconds prune_backoff{60};
99114

115+
/// Controls the backoff time when unsubscribing from a topic.
116+
///
117+
/// This is how long to wait before resubscribing to the topic. A short
118+
/// backoff period in case of an unsubscribe event allows reaching a healthy
119+
/// mesh in a more timely manner. The default is 10 seconds.
100120
std::chrono::seconds unsubscribe_backoff{10};
101121

122+
/// Number of heartbeat slots considered as slack for backoffs. This
123+
/// guarantees that we wait at least backoff_slack heartbeats after a
124+
/// backoff is over before we try to graft. This solves problems occurring
125+
/// through high latencies. In particular if `backoff_slack *
126+
/// heartbeat_interval` is longer than any latencies between processing
127+
/// prunes on our side and processing prunes on the receiving side this
128+
/// guarantees that we get not punished for too early grafting. The default
129+
/// is 1.
102130
size_t backoff_slack = 1;
103131

132+
/// Whether to do flood publishing or not. If enabled newly created messages
133+
/// will always be
134+
/// sent to all peers that are subscribed to the topic and have a good
135+
/// enough score. The default is true.
104136
bool flood_publish = true;
105137

138+
/// The maximum number of messages to include in an IHAVE message.
139+
/// Also controls the maximum number of IHAVE ids we will accept and request
140+
/// with IWANT from a peer within a heartbeat, to protect from IHAVE floods.
141+
/// You should adjust this value from the default if your system is pushing
142+
/// more than 5000 messages in GossipSubHistoryGossip heartbeats; with the
143+
/// defaults this is 1666 messages/s. The default is 5000.
106144
size_t max_ihave_length = 5000;
107145

108146
ScoreConfig score;

include/libp2p/protocol/gossip/score_config.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
namespace libp2p::protocol::gossip {
1010
struct ScoreConfig {
1111
double zero = 0;
12+
/// The score threshold below which gossip propagation is suppressed;
13+
/// should be negative.
1214
double gossip_threshold = -10;
15+
/// The score threshold below which we shouldn't publish when using flood
16+
/// publishing (also applies to fanout peers); should be negative and <=
17+
/// `gossip_threshold`.
1318
double publish_threshold = -50;
1419
};
1520
} // namespace libp2p::protocol::gossip

include/libp2p/protocol/gossip/time_cache.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace libp2p::protocol::gossip::time_cache {
1717
using Clock = std::chrono::steady_clock;
1818
using Time = Clock::time_point;
1919

20+
/// This implements a time-based LRU cache for checking gossipsub message
21+
/// duplicates.
2022
template <typename K, typename V>
2123
class TimeCache {
2224
public:

0 commit comments

Comments
 (0)