mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-03-01 08:30:29 +00:00
refactor(pubsub): do not raise exceptions on publish (#1244)
This commit is contained in:
parent
a4f0a638e7
commit
78a4344054
@ -194,7 +194,7 @@ method init*(f: FloodSub) =
|
||||
|
||||
method publish*(
|
||||
f: FloodSub, topic: string, data: seq[byte]
|
||||
): Future[int] {.async: (raises: [LPError]).} =
|
||||
): Future[int] {.async: (raises: []).} =
|
||||
# base returns always 0
|
||||
discard await procCall PubSub(f).publish(topic, data)
|
||||
|
||||
|
@ -705,7 +705,7 @@ method onTopicSubscription*(g: GossipSub, topic: string, subscribed: bool) =
|
||||
|
||||
method publish*(
|
||||
g: GossipSub, topic: string, data: seq[byte]
|
||||
): Future[int] {.async: (raises: [LPError]).} =
|
||||
): Future[int] {.async: (raises: []).} =
|
||||
logScope:
|
||||
topic
|
||||
|
||||
|
@ -555,7 +555,7 @@ proc subscribe*(p: PubSub, topic: string, handler: TopicHandler) {.public.} =
|
||||
|
||||
method publish*(
|
||||
p: PubSub, topic: string, data: seq[byte]
|
||||
): Future[int] {.base, async: (raises: [LPError]), public.} =
|
||||
): Future[int] {.base, async: (raises: []), public.} =
|
||||
## publish to a ``topic``
|
||||
##
|
||||
## The return value is the number of neighbours that we attempted to send the
|
||||
|
@ -65,7 +65,10 @@ proc init*(
|
||||
topic: string,
|
||||
seqno: Option[uint64],
|
||||
sign: bool = true,
|
||||
): Message {.gcsafe, raises: [LPError].} =
|
||||
): Message {.gcsafe, raises: [].} =
|
||||
if sign and peer.isNone():
|
||||
doAssert(false, "Cannot sign message without peer info")
|
||||
|
||||
var msg = Message(data: data, topic: topic)
|
||||
|
||||
# order matters, we want to include seqno in the signature
|
||||
@ -81,9 +84,6 @@ proc init*(
|
||||
.expect("Invalid private key!")
|
||||
.getBytes()
|
||||
.expect("Couldn't get public key bytes!")
|
||||
else:
|
||||
if sign:
|
||||
raise (ref LPError)(msg: "Cannot sign message without peer info")
|
||||
|
||||
msg
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user