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

refactor(iroh-net): remove iroh-net::config::Node since limited to its used fields it's redundant #1486

Merged

Conversation

divagant-martian
Copy link
Contributor

@divagant-martian divagant-martian commented Sep 17, 2023

Description

the Node type contains:

iroh/iroh-net/src/config.rs

Lines 157 to 174 in f2f3ead

pub struct Node {
/// The public key or PeerID, the primary identifier of this node.
pub key: PublicKey,
/// DNS name of the peer.
pub name: Option<String>,
/// Direct IP addresses of this Node.
///
/// These are the IP addresses this node is listening on.
pub addresses: Vec<IpAddr>,
/// Endpoints on which we think the node is reachable.
///
/// These are populated from STUN results as well as local LAN addresses.
pub endpoints: Vec<SocketAddr>,
/// DERP-in-IP:port ("127.3.3.40:N") endpoint. Only stores the `N`.
///
/// If this nodes expected to be reachable via DERP relaying.
pub derp: Option<u16>,
}

from these fields:

  • name is always None, so unused.
  • addresses is always calculated from the the endpoints so it can be removed.
    After this, the only remaining fields are the key, endpoints and derp region. This is equivalent to the NodeAddr type, making Node redundant
    /// Adress information for a node.
    #[derive(Debug)]
    pub struct NodeAddr {
    /// The node's public key.
    pub node_id: PublicKey,
    /// The node's home DERP region.
    pub derp_region: Option<u16>,
    /// Socket addresses where this node might be reached directly.
    pub endpoints: Vec<SocketAddr>,
    }

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

@divagant-martian divagant-martian changed the title refactor(iroh-net): cleanup Node refactor(iroh-net): remove iroh-net::config::Node since limited to its used fields it's redundant Sep 17, 2023
Copy link
Member

@Frando Frando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@divagant-martian divagant-martian added this pull request to the merge queue Sep 18, 2023
@divagant-martian divagant-martian self-assigned this Sep 18, 2023
Merged via the queue into n0-computer:main with commit 00d0150 Sep 19, 2023
@divagant-martian divagant-martian deleted the remove-unused-node-fields branch December 10, 2023 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants