mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-01-14 02:34:09 +00:00
remove sleeps
This commit is contained in:
parent
acdaeb8f5d
commit
9023bf786d
@ -413,8 +413,9 @@ method start*(g: GossipSub) {.async.} =
|
|||||||
|
|
||||||
# setup the heartbeat interval
|
# setup the heartbeat interval
|
||||||
g.heartbeatCancel = addInterval(GossipSubHeartbeatInterval,
|
g.heartbeatCancel = addInterval(GossipSubHeartbeatInterval,
|
||||||
proc (arg: pointer = nil) {.gcsafe, locks: 0.} =
|
proc (arg: pointer = nil)
|
||||||
asyncCheck g.heartbeat)
|
{.gcsafe, locks: 0.} =
|
||||||
|
asyncCheck g.heartbeat)
|
||||||
|
|
||||||
method stop*(g: GossipSub) {.async.} =
|
method stop*(g: GossipSub) {.async.} =
|
||||||
## stopt pubsub
|
## stopt pubsub
|
||||||
|
@ -107,11 +107,6 @@ proc pushTo*(s: BufferStream, data: seq[byte]) {.async.} =
|
|||||||
await s.lock.acquire()
|
await s.lock.acquire()
|
||||||
var index = 0
|
var index = 0
|
||||||
while true:
|
while true:
|
||||||
# give readers a chance free up the buffer
|
|
||||||
# it it's full.
|
|
||||||
if s.readBuf.len >= s.maxSize:
|
|
||||||
await sleepAsync(1.millis)
|
|
||||||
|
|
||||||
while index < data.len and s.readBuf.len < s.maxSize:
|
while index < data.len and s.readBuf.len < s.maxSize:
|
||||||
s.readBuf.addLast(data[index])
|
s.readBuf.addLast(data[index])
|
||||||
inc(index)
|
inc(index)
|
||||||
|
@ -190,7 +190,7 @@ suite "FloodSub":
|
|||||||
await node.publish("foobar", cast[seq[byte]]("Hello!"))
|
await node.publish("foobar", cast[seq[byte]]("Hello!"))
|
||||||
await sleepAsync(100.millis)
|
await sleepAsync(100.millis)
|
||||||
|
|
||||||
await sleepAsync(5000.millis)
|
await sleepAsync(1.minutes)
|
||||||
await allFutures(nodes.mapIt(it.stop()))
|
await allFutures(nodes.mapIt(it.stop()))
|
||||||
await allFutures(awaitters)
|
await allFutures(awaitters)
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ suite "FloodSub":
|
|||||||
await node.publish("foobar", cast[seq[byte]]("Hello!"))
|
await node.publish("foobar", cast[seq[byte]]("Hello!"))
|
||||||
await sleepAsync(100.millis)
|
await sleepAsync(100.millis)
|
||||||
|
|
||||||
await sleepAsync(5000.millis)
|
await sleepAsync(1.minutes)
|
||||||
await allFutures(nodes.mapIt(it.stop()))
|
await allFutures(nodes.mapIt(it.stop()))
|
||||||
await allFutures(awaitters)
|
await allFutures(awaitters)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
include ../../libp2p/protocols/pubsub/gossipsub
|
include ../../libp2p/protocols/pubsub/gossipsub
|
||||||
import testfloodsub,
|
import testgossipsub,
|
||||||
testgossipsub,
|
testfloodsub,
|
||||||
testmcache
|
testmcache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user