feat: ipns libp2p fetch
Title
feat: ipns libp2p fetch
Description
Adds @libp2p/fetch functionality to the pubsub router of helia/ipns.
The pubsub router will libp2p/fetch the latest local record from new pubsub peers if libp2p.services.fetch is found.
Closes #893
Notes & open questions
Should get method of the pubsub router wait for a few peers to be queries with fetch, or should the router emit an event when it finds a newer record?
Change checklist
- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation if necessary (this includes comments as well)
- [ ] I have added tests that prove my fix is effective or that my feature works
Does a lookup function need to be registered with @libp2p/fetch? It seems like it would be needed, but the resources I'm looking at don't use it.
I'm considering checking the current subscribers for the topic directly before the fetch call. The check would see if we are still pubsub peered with the peerId that is being queried with the fetch call. If not then cancel the fetch and return. This would reduce the possibility of opening a new connection instead of just a new stream.
Triage:
- @achingbrain will follow up