Skip to content

libp2p-kad: provide a way to get known addresses of a peer from address book #3633

@folex

Description

@folex

Description

Since Kademlia is basically an address book of peers (aka routing table), it would be great to be able to actually read from that address book. Check whether peer is presented in that address book or not.

For example, one might (and we do, see for example our fn discover_peer) use Kademlia to discover Peer address, establish connection, and exchange some messages.

But since addresses_of_peer is deprecated, and Kademlia::kbucket is private, how to read from the address book?

There's handle_pending_outbound_connection which is proposed to replace addresses_of_peer, but it implies an effect, since it signifies that a new connection happened. So it is a bad fit for the goal of "read address from Kademlia address book".

That being said, what are alternatives that you see viable?

Motivation

We need to read addresses from the Kademlia by PeerId, because we use Kademlia as a peers' addresses discovery mechanism.

In addition, I think it makes sense to separate "read model" from effectful methods like handle_pending_outbound_connection.

Current Implementation

We've relied on addresses_of_peer, but it is now removed from Kademlia completely.

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

Maybe, but need a guidance on the design and alignment with rust-libp2p team's vision.

Let's discuss!

I'm happy to provide more information on our use-case and discuss different design approaches.

Thank you for fast-paced development of rust-libp2p, it is a tremendous effort, and I really appreciate the complexity you are tackling! ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/author-inputNeeds input from the original author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions