expose seenTTL parameters (#457)

This commit is contained in:
Giovanni Petrantoni 2020-11-26 14:45:10 +09:00 committed by GitHub
parent ca9c5c85e4
commit 6c7f2766fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -121,6 +121,7 @@ type
historyGossip*: int historyGossip*: int
fanoutTTL*: Duration fanoutTTL*: Duration
seenTTL*: Duration
gossipThreshold*: float64 gossipThreshold*: float64
publishThreshold*: float64 publishThreshold*: float64
@ -195,6 +196,7 @@ proc init*(_: type[GossipSubParams]): GossipSubParams =
historyLength: GossipSubHistoryLength, historyLength: GossipSubHistoryLength,
historyGossip: GossipSubHistoryGossip, historyGossip: GossipSubHistoryGossip,
fanoutTTL: GossipSubFanoutTTL, fanoutTTL: GossipSubFanoutTTL,
seenTTL: 2.minutes,
gossipThreshold: -10, gossipThreshold: -10,
publishThreshold: -100, publishThreshold: -100,
graylistThreshold: -10000, graylistThreshold: -10000,
@ -1352,6 +1354,12 @@ method initPubSub*(g: GossipSub) =
g.parameters.validateParameters().tryGet() g.parameters.validateParameters().tryGet()
randomize() 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.mcache = MCache.init(g.parameters.historyGossip, g.parameters.historyLength)
g.mesh = initTable[string, HashSet[PubSubPeer]]() # meshes - topic to peer g.mesh = initTable[string, HashSet[PubSubPeer]]() # meshes - topic to peer
g.fanout = initTable[string, HashSet[PubSubPeer]]() # fanout - topic to peer g.fanout = initTable[string, HashSet[PubSubPeer]]() # fanout - topic to peer