libp2p / go-libp2p

libp2p implementation in Go
MIT License
6.02k stars 1.06k forks source link

[Peerstore] Event driven peerstore #802

Open aarshkshah1992 opened 4 years ago

aarshkshah1992 commented 4 years ago

See https://github.com/libp2p/specs/issues/164 for a great writeup on why we want to do this.

Rather than callers listening to Network events/notifications & changing the state of the data(addresses, keys, supported protocols etc.) in the peerstore via it's API, the peerstore itself should listen to events such as Connected,Disconnected, Identify Completed etc. on the Eventbus & mutate it's internal data accordingly.

https://github.com/libp2p/go-libp2p/issues/801 should be completed before this.

burdiyan commented 1 year ago

Since https://github.com/libp2p/specs/issues/164 is closed now, I'm posting my concern here as well:

How large is all this peer-related information? If the amount of data per peer is small, and even for hundreds of peers it is still in the order of megabytes, maybe a simpler cleanup approach could suffice? Like cleaning up less recently used peer information once in a while, instead of trying to do it in a more real-time fashion?

So, the question is, is it really necessary to constantly trying to purge the address book, creating a lot of writes and potentially saturating the datastore? If peer data is small enough, and there's not a lot of churn of peers, maybe it's worth keeping the peer data for longer?