Always publish to at least dLow

This commit is contained in:
Tanguy 2023-06-13 15:47:44 +02:00
parent 8f78a349ed
commit 50aaaf4784
No known key found for this signature in database
GPG Key ID: 7DD8EC6B6CE6C45E
2 changed files with 4 additions and 5 deletions

View File

@ -500,7 +500,7 @@ method publish*(g: GossipSub,
bandwidth = 25_000_000 #TODO replace with bandwidth estimate
msToTransmit = max(msgSize div (bandwidth div 1000), 1)
maxFloodPublish =
(g.parameters.heartbeatInterval.milliseconds div msToTransmit)
max(g.parameters.heartbeatInterval.milliseconds div msToTransmit, g.parameters.dLow)
# With flood publishing enabled, the mesh is used when propagating messages from other peers,
# but a peer's own messages will always be published to all known peers in the topic, limited
# to the amount of peers we can send it to in one heartbeat
@ -510,12 +510,11 @@ method publish*(g: GossipSub,
trace "publish: including flood/high score peer", peer
peers.incl(peer)
if peers.len < g.parameters.dLow and g.parameters.floodPublish == false:
if peers.len < g.parameters.dLow:
# not subscribed or bad mesh, send to fanout peers
# disable for floodPublish, since we already sent to every good peer
#
var fanoutPeers = g.fanout.getOrDefault(topic).toSeq()
if fanoutPeers.len == 0:
if fanoutPeers.len < g.parameters.dLow:
g.replenishFanout(topic)
fanoutPeers = g.fanout.getOrDefault(topic).toSeq()

View File

@ -561,8 +561,8 @@ proc replenishFanout*(g: GossipSub, topic: string) {.raises: [].} =
logScope: topic
trace "about to replenish fanout"
let currentMesh = g.mesh.getOrDefault(topic)
if g.fanout.peers(topic) < g.parameters.dLow:
let currentMesh = g.mesh.getOrDefault(topic)
trace "replenishing fanout", peers = g.fanout.peers(topic)
for peer in g.gossipsub.getOrDefault(topic):
if peer in currentMesh: continue