actually lock the heartbeat

This commit is contained in:
Giovanni Petrantoni 2020-07-04 14:09:42 +09:00
parent ad7db1ca26
commit aed8dcadaf

View File

@ -189,7 +189,9 @@ proc getGossipPeers(g: GossipSub): Table[string, ControlMessage] {.gcsafe.} =
proc heartbeat(g: GossipSub) {.async.} =
while g.heartbeatRunning:
await g.heartbeatLock.acquire()
try:
trace "running heartbeat"
for t in toSeq(g.topics.keys):
@ -213,6 +215,8 @@ proc heartbeat(g: GossipSub) {.async.} =
raise exc
except CatchableError as exc:
trace "exception ocurred in gossipsub heartbeat", exc = exc.msg
finally:
g.heartbeatLock.release()
await sleepAsync(1.seconds)