add floodPublish logic
This commit is contained in:
parent
cf51da00b2
commit
ec5c0b867d
|
@ -59,6 +59,8 @@ type
|
||||||
dScore: int
|
dScore: int
|
||||||
dOut: int
|
dOut: int
|
||||||
|
|
||||||
|
publishThreshold: float
|
||||||
|
|
||||||
GossipSub* = ref object of FloodSub
|
GossipSub* = ref object of FloodSub
|
||||||
parameters*: GossipSubParams
|
parameters*: GossipSubParams
|
||||||
mesh*: Table[string, HashSet[string]] # meshes - topic to peer
|
mesh*: Table[string, HashSet[string]] # meshes - topic to peer
|
||||||
|
@ -529,6 +531,12 @@ method publish*(g: GossipSub,
|
||||||
var peers = g.explicitPeers
|
var peers = g.explicitPeers
|
||||||
|
|
||||||
if data.len > 0 and topic.len > 0:
|
if data.len > 0 and topic.len > 0:
|
||||||
|
if g.parameters.floodPublish:
|
||||||
|
for id, peer in g.peers:
|
||||||
|
if peer.topics.find(topic) != -1 and
|
||||||
|
peer.score() >= g.parameters.publishThreshold:
|
||||||
|
peers.incl(id)
|
||||||
|
|
||||||
if topic in g.topics: # if we're subscribed to the topic attempt to build a mesh
|
if topic in g.topics: # if we're subscribed to the topic attempt to build a mesh
|
||||||
await g.rebalanceMesh(topic)
|
await g.rebalanceMesh(topic)
|
||||||
peers.incl(g.mesh.getOrDefault(topic))
|
peers.incl(g.mesh.getOrDefault(topic))
|
||||||
|
|
Loading…
Reference in New Issue