-
Notifications
You must be signed in to change notification settings - Fork 975
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
misc: add a PeerStore
behaviour
#4103
Comments
In general I am in favor of a In addition to the above, I suggest adding a new variant to We could then deprecate rust-libp2p/protocols/identify/src/behaviour.rs Lines 53 to 54 in 85a846a
|
Good idea. That is orthogonal though, correct? We can ship an initial peer store without introducing such a variant (which is a breaking change). A |
Should be simple to do from the behaviour standpoint. Maybe we could do a trait similar to libp2p-kad store that can be used for others to implement their own backend besides the memory backend. Also, I think storing in memory is fine for now, which is what I usually do although storing it elsewhere (eg database, on-disk, etc) is a nice-to-have solution down the road, but dont think it really fits the scope of rust-libp2p. |
The question is, is it worth doing the abstraction of a trait and deal with all the issues of e.g. futures that need to run on a specific executor (thinking tokio-postgresql etc) over just requiring people to implement another |
Tracked in #4302. |
Another thing to consider is that reading from this store needs to be synchronous and fast because we do it for every outgoing connection. Thus, the entire list needs to be in-memory anyway. Storing peer addresses in a database or disk does make sense though. I think we can accommodate for that by:
The above would allow users to integrate the peer store into an event loop and synchronize its state with another data source or sink. It would only be eventually-consistent but I think that is fine. |
With #4371 approved, this issue is now unblocked. |
Lessons from go-libp2p: libp2p/go-libp2p#2355 |
Description
Other implementations have the concept of a
PeerStore
, should we add one torust-libp2p
too? I am thinking of aNetworkBehaviour
implementation tracks currently connected peers and allows to add / remove addresses.See related discussions:
Behaviour::connected
andBehaviour::addresses
#4101Motivation
Users should be able to query the connected peers in a simple way and add known addresses of peers that will contribute to establishing new connections.
Open questions
Are you planning to do it yourself in a pull request?
No
The text was updated successfully, but these errors were encountered: