Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist peers for bootstrapping #2987

Closed
Winterhuman opened this issue Oct 5, 2022 · 4 comments
Closed

Persist peers for bootstrapping #2987

Winterhuman opened this issue Oct 5, 2022 · 4 comments

Comments

@Winterhuman
Copy link

Winterhuman commented Oct 5, 2022

Description

Mirroring libp2p/go-libp2p-kad-dht#254, it would be great if long-lasting peers were persisted and used for bootstrapping later.

Motivation

Using bootstrap nodes outside of the default ones improves network resiliency, and potentially improves initial connections times when the new bootstrap nodes are closer than they otherwise would be.

Requirements

  1. Save the longest lasting peer(s) from each k-bucket where it can be re-used for bootstrapping.

Open questions

Are you planning to do it yourself in a pull request?

No

@dariusc93
Copy link
Member

If im understanding the issue correctly, one could implement their own store for RecordStore. Something like sled or rocksdb could be a good place to start for persistence and move up from there for different backend stores, though something to be included for rust-libp2p is hard to say. Mostly feel that it should be an outside implementation.

@Winterhuman
Copy link
Author

Perhaps you're right, I mainly opened this to mirror libp2p/go-libp2p-kad-dht#254 which targets go-libp2p as opposed to Kubo, although ipfs/kubo#8856 being open at the same time confuses things as to where this sort of code should belong

@thomaseizinger
Copy link
Contributor

In rust-libp2p, PeerIds are resolved to addresses by querying all configured behaviours via NetworkBehaviour::addresses_of_peer. It should be relatively straight-forward to implement your own NetworkBehaviour that extracts addresses from the NetworkBehaviour::inject_connection_established callback, stores them in some persistent way and queries that storage whenever addresses_of_peer is called.

To avoid latency issues, I'd be best to not do any IO in the NetworkBehaviour::poll method as that is run as part of the main event loop of a Swarm.

@Winterhuman
Copy link
Author

Closing since this can be implemented independently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants