Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

RFC: async iterator based discovery #27

@alanshaw

Description

@alanshaw

I've been exploring what an async iterator based discovery interface might look like. The following gist is a rough sketch (very unlikely to actually run) of what it could be like.

TLDR: it's just an (async) iterator that yields PeerInfo instances.

In the gist I've explored what it might be like to use these in a libp2p node, which would need for them to be abortable (stop when the libp2p node stops) and recoverable (when they error, restart them).

To be abortable I've used an AbortController which is used by the fetch API in the browser. This is just one way of giving us the ability to halt async iteration from the outside (it's kinda cool IMHO). We could use this to implement abortable methods throughout libp2p.

We should talk about what happens when we recieve a PeerInfo from a discovery module and how we can communicate that to where it needs to be.

https://gist.github.com/alanshaw/ff657468939a1795aa5b9ac626121c48

@libp2p/javascript-team I'd love to hear your thoughts on this! 🚀 ✨


refs ipfs/js-ipfs#1670

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions