From 6c7f2766fe67400d48765acb1d2c0c7d9e758b90 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Thu, 26 Nov 2020 14:45:10 +0900 Subject: [PATCH] expose seenTTL parameters (#457) --- libp2p/protocols/pubsub/gossipsub.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim index 7e50a092a..5c4f2ae0e 100644 --- a/libp2p/protocols/pubsub/gossipsub.nim +++ b/libp2p/protocols/pubsub/gossipsub.nim @@ -121,6 +121,7 @@ type historyGossip*: int fanoutTTL*: Duration + seenTTL*: Duration gossipThreshold*: float64 publishThreshold*: float64 @@ -195,6 +196,7 @@ proc init*(_: type[GossipSubParams]): GossipSubParams = historyLength: GossipSubHistoryLength, historyGossip: GossipSubHistoryGossip, fanoutTTL: GossipSubFanoutTTL, + seenTTL: 2.minutes, gossipThreshold: -10, publishThreshold: -100, graylistThreshold: -10000, @@ -1352,6 +1354,12 @@ method initPubSub*(g: GossipSub) = g.parameters.validateParameters().tryGet() randomize() + + # init the floodsub stuff here, we customize timedcache in gossip! + g.floodsub = initTable[string, HashSet[PubSubPeer]]() + g.seen = TimedCache[MessageID].init(g.parameters.seenTTL) + + # init gossip stuff g.mcache = MCache.init(g.parameters.historyGossip, g.parameters.historyLength) g.mesh = initTable[string, HashSet[PubSubPeer]]() # meshes - topic to peer g.fanout = initTable[string, HashSet[PubSubPeer]]() # fanout - topic to peer