go-libp2p-daemon icon indicating copy to clipboard operation
go-libp2p-daemon copied to clipboard

Expose the Peerstore

Open jacobheun opened this issue 5 years ago • 7 comments

Expose the Peerstore to allow daemon clients to access that information, such as known protocols a peer supports.

~~I'm proposing an addition of protos to the PeerInfo protobuf. This would enable us to expose the known protocols of a peer to consuming clients during the LIST_PEERS request.~~

jacobheun avatar Mar 19 '19 13:03 jacobheun

I am not too excited about that.

vyzo avatar Mar 19 '19 15:03 vyzo

PeerInfo is used in LIST_PEERS and in DHT requests.

Sorry but i can't see any use-cases for LIST_PEERS, but i see how it can be used in DHT. But i think its not possible in current version of DHT to obtain list of protocols supported by peer, or i'm wrong? @vyzo

cheatfate avatar Mar 19 '19 16:03 cheatfate

The protocols are discovered and added to the Peer Store during Identify, there's just currently no trivial way for us to get those known protocols from the Daemon. Right now the only access we have to the Peer Store is LIST_PEERS. I'd like to be able to get this information from the Daemon about a given peer.

I am not too excited about that.

@vyzo is it the usage in LIST_PEERS, or exposing the protocols period?

jacobheun avatar Mar 19 '19 18:03 jacobheun

You can use identify directly on a peer.

vyzo avatar Mar 19 '19 18:03 vyzo

Unless I am missing something, the only way to currently use identify directly on a peer would be to implement the identify protocol in a daemon client and perform that on a connected peer.

IDENTIFY currently only applies to the daemon itself.

jacobheun avatar Mar 20 '19 08:03 jacobheun

It's trivial, you just open a stream and read the identify response.

Having said that, we probably want to expose the Peerstore where such information can be obtained. I don't want to extend the PeerInfo struct though, it's a kludge.

vyzo avatar Mar 20 '19 10:03 vyzo

Exposing the Peerstore would be ideal.

I can create a PR for the proto and Spec additions.

jacobheun avatar Mar 20 '19 11:03 jacobheun