This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
Better feedback when using publish
#96
Labels
exp/expert
Having worked on the specific codebase is important
need/analysis
Needs further analysis before proceeding
need/community-input
Needs input from the wider community
P3
Low: Not priority right now
The
Publish
method is currently defined to returnPromise<void>
.However, from experience, there can be a number of reasons for which a message is not sent to any peer.
The current
publish
method seems to be a shot in the dark.I would propose to update the interface to return some information on the attempt made by the method to send messages. At this stage I would be interesting to know if the method successfully sent the message to at least one peer so returning
Promise<boolean>
could be enough.However, with a mindset of extensibility, returning the following could give more options to API consumers:
With
success
the peers for which it seems that the message was sent, ie, no error was raised from the stream, etc.fail
the peers that were selected for publishing but some error was returned.Note: Maybe
success
is not the right terminology as I understand messages are not ack'd.attempted
andimmediateFail
could be an alternative naming.I assume that'd I need to play around with the code first to confirm that said API would make sense.
If we look other implementations such as rust-libp2p, the
publish
method returns a result (back to the boolean) where, for example, an error is returned if no peers were selected:https://github.com/libp2p/rust-libp2p/blob/c5bcada2c2a1e34b8e39b885f10ed7c2d00e8373/protocols/gossipsub/src/behaviour.rs#L681
Thoughts?
The text was updated successfully, but these errors were encountered: