Fix after gcsafe requirements change and other issues on devel (#795)

This commit is contained in:
diegomrsantos 2022-11-05 02:04:05 +01:00 committed by GitHub
parent d9305bda84
commit 6ab6ab48ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -108,6 +108,7 @@ task examples_build, "Build the samples":
buildSample("tutorial_4_gossipsub", true) buildSample("tutorial_4_gossipsub", true)
buildSample("tutorial_5_discovery", true) buildSample("tutorial_5_discovery", true)
# Nico doesn't work in 1.2 # 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" exec "nimble install -y nico"
buildSample("tutorial_6_game", false, "--styleCheck:off") buildSample("tutorial_6_game", false, "--styleCheck:off")

View File

@ -130,7 +130,7 @@ type
knownTopics*: HashSet[string] knownTopics*: HashSet[string]
method unsubscribePeer*(p: PubSub, peerId: PeerId) {.base.} = method unsubscribePeer*(p: PubSub, peerId: PeerId) {.base, gcsafe.} =
## handle peer disconnects ## handle peer disconnects
## ##
@ -377,7 +377,7 @@ method handleConn*(p: PubSub,
finally: finally:
await conn.closeWithEOF() 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 ## subscribe to remote peer to receive/send pubsub
## messages ## messages
## ##
@ -400,7 +400,7 @@ proc updateTopicMetrics(p: PubSub, topic: string) =
libp2p_pubsub_topic_handlers.set(others, labelValues = ["other"]) 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 # Called when subscribe is called the first time for a topic or unsubscribe
# removes the last handler # removes the last handler
@ -433,7 +433,7 @@ proc unsubscribe*(p: PubSub, topics: openArray[TopicPair]) {.public.} =
for t in topics: for t in topics:
p.unsubscribe(t.topic, t.handler) 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` ## unsubscribe every `handler` from `topic`
if topic notin p.topics: if topic notin p.topics:
debug "unsubscribeAll called for an unknown topic", topic debug "unsubscribeAll called for an unknown topic", topic
@ -495,7 +495,7 @@ method initPubSub*(p: PubSub)
method addValidator*(p: PubSub, method addValidator*(p: PubSub,
topic: varargs[string], topic: varargs[string],
hook: ValidatorHandler) {.base, public.} = hook: ValidatorHandler) {.base, public, gcsafe.} =
## Add a validator to a `topic`. Each new message received in this ## Add a validator to a `topic`. Each new message received in this
## will be sent to `hook`. `hook` can return either `Accept`, ## will be sent to `hook`. `hook` can return either `Accept`,
## `Ignore` or `Reject` (which can descore the peer) ## `Ignore` or `Reject` (which can descore the peer)