remove sleeps

This commit is contained in:
Dmitriy Ryajov 2020-02-13 13:04:30 -05:00
parent acdaeb8f5d
commit 9023bf786d
5 changed files with 12 additions and 16 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -1,4 +1,4 @@
include ../../libp2p/protocols/pubsub/gossipsub include ../../libp2p/protocols/pubsub/gossipsub
import testfloodsub, import testgossipsub,
testgossipsub, testfloodsub,
testmcache testmcache

View File

@ -2,13 +2,13 @@ import testvarint
import testrsa, testecnist, tested25519, testsecp256k1, testcrypto import testrsa, testecnist, tested25519, testsecp256k1, testcrypto
import testmultibase, testmultihash, testmultiaddress, testcid, testpeer import testmultibase, testmultihash, testmultiaddress, testcid, testpeer
import testtransport, import testtransport,
testmultistream, testmultistream,
testbufferstream, testbufferstream,
testidentify, testidentify,
testswitch, testswitch,
testpeerinfo, testpeerinfo,
pubsub/testpubsub, pubsub/testpubsub,
# TODO: placing this before pubsub tests, # TODO: placing this before pubsub tests,
# breaks some flood and gossip tests - no idea why # breaks some flood and gossip tests - no idea why
testmplex testmplex