From 6ab6ab48ef2013c8cec39e78b810356d6bf28176 Mon Sep 17 00:00:00 2001 From: diegomrsantos Date: Sat, 5 Nov 2022 02:04:05 +0100 Subject: [PATCH] Fix after gcsafe requirements change and other issues on devel (#795) --- libp2p.nimble | 1 + libp2p/protocols/pubsub/pubsub.nim | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libp2p.nimble b/libp2p.nimble index ff4f8bd65..301e7c165 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -108,6 +108,7 @@ task examples_build, "Build the samples": buildSample("tutorial_4_gossipsub", true) buildSample("tutorial_5_discovery", true) # Nico doesn't work in 1.2 + exec "nimble install -y nimpng@#HEAD" # this is to fix broken build on 1.7.3, remove it when nimpng version 0.3.2 or later is released exec "nimble install -y nico" buildSample("tutorial_6_game", false, "--styleCheck:off") diff --git a/libp2p/protocols/pubsub/pubsub.nim b/libp2p/protocols/pubsub/pubsub.nim index a7d7fc210..ab010a366 100644 --- a/libp2p/protocols/pubsub/pubsub.nim +++ b/libp2p/protocols/pubsub/pubsub.nim @@ -130,7 +130,7 @@ type knownTopics*: HashSet[string] -method unsubscribePeer*(p: PubSub, peerId: PeerId) {.base.} = +method unsubscribePeer*(p: PubSub, peerId: PeerId) {.base, gcsafe.} = ## handle peer disconnects ## @@ -377,7 +377,7 @@ method handleConn*(p: PubSub, finally: await conn.closeWithEOF() -method subscribePeer*(p: PubSub, peer: PeerId) {.base.} = +method subscribePeer*(p: PubSub, peer: PeerId) {.base, gcsafe.} = ## subscribe to remote peer to receive/send pubsub ## messages ## @@ -400,7 +400,7 @@ proc updateTopicMetrics(p: PubSub, topic: string) = libp2p_pubsub_topic_handlers.set(others, labelValues = ["other"]) -method onTopicSubscription*(p: PubSub, topic: string, subscribed: bool) {.base.} = +method onTopicSubscription*(p: PubSub, topic: string, subscribed: bool) {.base, gcsafe.} = # Called when subscribe is called the first time for a topic or unsubscribe # removes the last handler @@ -433,7 +433,7 @@ proc unsubscribe*(p: PubSub, topics: openArray[TopicPair]) {.public.} = for t in topics: p.unsubscribe(t.topic, t.handler) -proc unsubscribeAll*(p: PubSub, topic: string) {.public.} = +proc unsubscribeAll*(p: PubSub, topic: string) {.public, gcsafe.} = ## unsubscribe every `handler` from `topic` if topic notin p.topics: debug "unsubscribeAll called for an unknown topic", topic @@ -495,7 +495,7 @@ method initPubSub*(p: PubSub) method addValidator*(p: PubSub, topic: varargs[string], - hook: ValidatorHandler) {.base, public.} = + hook: ValidatorHandler) {.base, public, gcsafe.} = ## Add a validator to a `topic`. Each new message received in this ## will be sent to `hook`. `hook` can return either `Accept`, ## `Ignore` or `Reject` (which can descore the peer)