@@ -17,6 +17,8 @@ proc createMessageHandler(): proc(topic: string, data: seq[byte]) {.async, gcsaf
1717 var messagesChunks: CountTable [uint64 ]
1818
1919 return proc (topic: string , data: seq [byte ]) {.async , gcsafe .} =
20+ echo " RECV: " , data.len
21+ #[
2022 let sentUint = uint64.fromBytesLE(data)
2123 # warm-up
2224 if sentUint < 1000000:
@@ -30,6 +32,7 @@ proc createMessageHandler(): proc(topic: string, data: seq[byte]) {.async, gcsaf
3032 sentNanosecs = nanoseconds(sentMoment - seconds(sentMoment.seconds))
3133 sentDate = initTime(sentMoment.seconds, sentNanosecs)
3234 diff = getTime() - sentDate
35+ ]#
3336
3437proc messageValidator (topic: string , msg: Message ): Future [ValidationResult ] {.async .} =
3538 return ValidationResult .Accept
@@ -89,8 +92,6 @@ proc connectGossipsubPeers(
8992 return ok (connected)
9093
9194proc subscribGossipsubTopic (gossipSub: GossipSub , topic: string ) =
92-
93-
9495 gossipSub.subscribe (topic, createMessageHandler ())
9596 gossipSub.addValidator ([topic], messageValidator)
9697
@@ -179,11 +180,13 @@ proc main() {.async.} =
179180
180181 info " Starting listening endpoint for publish controller"
181182
182- while true :
183- discard await gossipSub.publishNewMessage (50 * 1024 , " test" )
184- await sleepAsync (5 .seconds)
183+ let x = proc () {.async .} =
184+ while true :
185+ discard await gossipSub.publishNewMessage (50 * 1024 , " test" )
186+ await sleepAsync (5 .seconds)
185187
188+ asyncSpawn x ()
186189
187- await sleepAsync (2 .days )
190+ await sleepAsync (10 .minutes )
188191
189192waitFor (main ())
0 commit comments