-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(iroh-net): Make derp_map not an option in MagicEndpoint #1363
Conversation
This removes the Option from MagicEndpoint::derp_map. An empty DerpMap is treated the same as a missing DerpMap in all the code so this is just a noisy indirection.
Allowing |
You can still do this by using an empty |
oh wait, the public API still has it as an option, but with a TODO to consider this. So yes the question is both about the internal and external api. I think internal it makes sense. External maybe too and I could like a |
I would like to see sth like this enum Derp {
Enabled(DerpMap), // Constructor checks that this is not empty and the node checks that at least the local region id is available
Disabled,
} |
So the only really public API is the This PR started as just acknowledging that internally the code does not ever distinguish a I think switching internally to this |
for the public api I would do sth like disable_derp() and enable_derp(map) which forces map to not be empty |
you are right internal is annoying and we should just drop the optiob there for now |
I've now updated the public API to be I've moved validation of the DerpMap into the constructors itself, the constructor is basically (I tried having this constructor in |
can you update the |
This is much more consistent. Note that this also changes the default derp servers.
oh yes, good call. sorry to gloss over that at first. Note that I also changed the default |
An empty DerpMap is valid so can be constructed. But in the public builder APIs we still want to reject this.
Description
This changes the public API to set the derp map to enable_derp(derp_map)
and disable_derp(). As part of this the DerpMap itself is changed so it
can only be constructed as a valid DerpMap and consistency checks are made.
The public endpoints also ensure the derp map is not empty.
Internally this removes the Option from MagicEndpoint::derp_map. An empty
DerpMap is treated the same as a missing DerpMap in all the code so
this is just a noisy indirection.
Notes & open questions
Change checklist