Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4014/docs/iroh/ Last updated: 2026-03-16T11:41:14Z |
|
|
||
| // Build a `Endpoint`, which uses PublicKeys as endpoint identifiers, uses QUIC for directly connecting to other endpoints, and uses the relay protocol and relay servers to holepunch direct connections between endpoints when there are NATs or firewalls preventing direct connections. If no direct connection can be made, packets are relayed over the relay servers. | ||
| let endpoint = Endpoint::builder() | ||
| let endpoint = Endpoint::builder(presets::N0) |
There was a problem hiding this comment.
Not super sure but I think I'd prefer N0Preset to presets::N0, i.e. rename N0 to N0Preset. People use auto-imports and then you'd often have N0 which reads weird. Also N0Preset is better discoverable with auto-complete. maye PresetN0 would be even better for autocomplete, unsure.
This is not new to this PR, but this PR makes presets appear at many more places, so this warrants a new discussion on this I think.
Frando
left a comment
There was a problem hiding this comment.
I like it.
I'll miss Endpoint::bind() I think, but @okdistribute argued well that we should not ship n0 defaults silently. Endpoint::bind(preset::N0) (or maybe Endpoint::bind(N0Preset), tbd) is still reasonably short for examples etc and makes things obvious. So yeah, let's do this.
We current default builder approach harcodes the number 0 servers directly, to make this more explicit, but still have a clean API for examples everywhere this refactors the builder and bind API of the endpoint.
6fff5c3 to
2062180
Compare
|
I am very much in favour of requiring presets everywhere, simply because having a preset going away due to a feature flag being disabled is much less weird than an essential fn like bind() or builder() going away or changing behaviour. |
Description
The current default builder approach hardcodes the number 0 servers directly, to make this more explicit, but still have a clean API for examples everywhere this refactors the builder and bind API of the endpoint.
Breaking Changes
iroh::Endpoint::buildernow takes a presetiroh::Endpoint::bindnow takes a presetiroh::Endpoint::empty_buildernow assumesRelayMode::Disabledand takes no argumentsiroh::EndpointBuilder::emptynow assumesRelayMode::Disabledand takes no argumentsExample