mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-01-12 19:34:23 +00:00
fix ci
This commit is contained in:
parent
50aaaf4784
commit
30e0dae40a
@ -510,17 +510,15 @@ method publish*(g: GossipSub,
|
||||
trace "publish: including flood/high score peer", peer
|
||||
peers.incl(peer)
|
||||
|
||||
if peers.len < g.parameters.dLow:
|
||||
# not subscribed or bad mesh, send to fanout peers
|
||||
#
|
||||
if peers.len < g.parameters.dLow and topic notin g.topics:
|
||||
# not subscribed send, to fanout peers
|
||||
var fanoutPeers = g.fanout.getOrDefault(topic).toSeq()
|
||||
if fanoutPeers.len < g.parameters.dLow:
|
||||
g.replenishFanout(topic)
|
||||
fanoutPeers = g.fanout.getOrDefault(topic).toSeq()
|
||||
|
||||
g.rng.shuffle(fanoutPeers)
|
||||
if fanoutPeers.len + peers.len > g.parameters.d:
|
||||
fanoutPeers.setLen(g.parameters.d - peers.len)
|
||||
fanoutPeers.capLen(g.parameters.d - peers.len)
|
||||
|
||||
for fanPeer in fanoutPeers:
|
||||
peers.incl(fanPeer)
|
||||
@ -533,6 +531,19 @@ method publish*(g: GossipSub,
|
||||
# time
|
||||
g.lastFanoutPubSub[topic] = Moment.fromNow(g.parameters.fanoutTTL)
|
||||
|
||||
if peers.len < g.parameters.dLow:
|
||||
# Bad mesh, just send to whoever
|
||||
var allPeers = toSeq(g.gossipsub.getOrDefault(topic))
|
||||
g.rng.shuffle(allPeers)
|
||||
for peer in allPeers:
|
||||
if peers.len >= g.parameters.dLow: break
|
||||
if peer.score >= g.parameters.publishThreshold:
|
||||
peers.incl(peer)
|
||||
|
||||
for peer in allPeers:
|
||||
if peers.len >= g.parameters.dLow: break
|
||||
peers.incl(peer)
|
||||
|
||||
if peers.len == 0:
|
||||
let topicPeers = g.gossipsub.getOrDefault(topic).toSeq()
|
||||
debug "No peers for topic, skipping publish", peersOnTopic = topicPeers.len,
|
||||
|
@ -70,6 +70,10 @@ template safeConvert*[T: SomeInteger, S: Ordinal](value: S): T =
|
||||
else:
|
||||
{.error: "Source and target types have an incompatible range low..high".}
|
||||
|
||||
proc capLen*[T](s: var seq[T], length: Natural) =
|
||||
if s.len > length:
|
||||
s.setLen(length)
|
||||
|
||||
template exceptionToAssert*(body: untyped): untyped =
|
||||
block:
|
||||
var res: type(body)
|
||||
|
Loading…
x
Reference in New Issue
Block a user