Skip to content
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

feat(net): Make ListenConfig Parameterized #40

Closed
refcell opened this issue Aug 26, 2024 · 4 comments · Fixed by #54
Closed

feat(net): Make ListenConfig Parameterized #40

refcell opened this issue Aug 26, 2024 · 4 comments · Fixed by #54
Assignees
Labels
A-net Area: Network crate

Comments

@refcell
Copy link
Collaborator

refcell commented Aug 26, 2024

Description

#34 introduces peer discovery, configuring discv5 to listen to a specified socket address.

This ticket is to refactor out the ListenConfig so that it can be parameterized.

@refcell refcell added the A-net Area: Network crate label Aug 26, 2024
@GrapeBaBa
Copy link
Contributor

GrapeBaBa commented Aug 27, 2024

Does it mean refactor like this? It seems a change in the discv5 repo?

#[derive(Clone, Debug)]
pub enum ListenConfig<T: Into<IpAddr> = IpAddr> {
    Ip {
        ip: T,
        port: u16,
    },
    DualStack {
        ipv4: T,
        ipv4_port: u16,
        ipv6: T,
        ipv6_port: u16,
    },
}

@refcell
Copy link
Collaborator Author

refcell commented Aug 27, 2024

Ah yes sorry for causing confusion, I see how that wording can be misinterpreted.

What I meant was the net crate currently builds the discovery service and manually constructs the ListenConfig using the address and port here.

We'd like to "parameterize" this by adding a with_listen_config function on the builder that allows the consumer of the net crate to specify the entire ListenConfig object, and if not, it defaults to this singular address+port construction.

Since the entire network stack is constructed using the top-level builder, which builds the discovery service, we should probably add the with_listen_config method to the top-level NetworkDriverBuilder as well and set it on the discovery builder here.

Effectively this "parameterizes" the listen config since a downstream user of the net crate can pass an instantiation of the ListenConfig into the NetworkDriverBuilder as an argument 😄

@GrapeBaBa
Copy link
Contributor

Ok, can I pick this?

@refcell
Copy link
Collaborator Author

refcell commented Aug 27, 2024

Ok, can I pick this?

Certainly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-net Area: Network crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants