Open rklaehn opened 11 months ago
We got mainline DHT node discovery in iroh-examples, see https://github.com/n0-computer/iroh-examples/tree/main/iroh-pkarr-node-discovery
We are also working on integrating this more tightly and adding DNS as a resolution mechanism.
As discussed, we should have the ability to dial by peer directly in the endpoint.
I would propose roughly the following:
We allow hooking up a discovery service to the magic endpoint in the builder. This can be None initially, or can point to some centralized iroh discovery service.
The discovery service gets called every time our own addr info changes, and can decide whether the change is important enough to publish something or not. E.g. you might not want to publish addr changes but only region changes.
The discovery service gets called when connecting by peer, if we don't have info in the peer map
examples of a discovery service would be the mainline dht, mdns, a centralized service, or some combination. See https://github.com/dvc94ch/p2p/blob/master/src/discovery.rs by @dvc94ch, using pkarr by @Nuhvi and mdns.
connect currently is just adding info to the peer map and then connecting by peer. So we could change it to be just a convenience method for
add_peer_addr
followed byconnect_by_peer
.