/// Parse a --nodes flag value in to a Node.
///
/// This approach is deprecated -- it doesn't support specifying multiple
/// values for different endpoints, the protocols, and so on. It exists
/// for backwards compatbility with deployment tooling, and will be removed
/// when that has been updated.
// TODO(O4-43) Remove --nodes flag
Parse a --nodes flag value in to a Node.
This approach is deprecated -- it doesn't support specifying multiple
values for different endpoints, the protocols, and so on. It exists
for backwards compatbility with deployment tooling, and will be removed
when that has been updated.
Parse a -- nodes flag value in to a Node . This approach is deprecated -- it doesn ' t support specifying multiple values for different endpoints the protocols and so on . It exists for backwards compatbility with deployment tooling and will be removed when that has been updated .
fn parse_nodes_deprecated(src: &str) -> Result<Node> {
    // We allow for both, the comma (',') and dash ('-'), to be used as separators
    // of tuple components. The dash ('-') conflicts with using domain names
    // containing dashes in place of ip addresses.
    // TODO(RPL-255): The goal is to switch to commas (',') entirely, but we will
    // remain backwards compatible for the moment.
    let separator = if src.contains(',') { ',' } else { '-' };
    let parts = src.splitn(6, separator).collect::<Vec<&str>>();
    let node_index = parts[0].parse::<u64>().unwrap();
    let subnet_part = parts[1];
    let subnet_index = if subnet_part.is_empty() {
        None
    } else {
        Some(subnet_part.parse::<u64>().unwrap())
    };
    // For most endpoints default to `http` as the protocol, which is consistent
    // with existing behaviour for this flag.
    let xnet_addr: SocketAddr = parts[3]
        .parse()
        .with_context(|| format!("did not parse {} as SocketAddr", parts[3]))?;
    // Default to listening on 0.0.0.0 for metrics (consistent with past
    // behaviour)
    let metrics_port = parts[4].parse::<u16>().unwrap();
    let metrics_addr: SocketAddr =
        SocketAddrV4::new("0.0.0.0".parse().expect("can't fail"), metrics_port).into();
    let http_addr: SocketAddr = parts[5]
        .parse()
        .with_context(|| format!("did not parse {} as SocketAddr", parts[3]))?;
    // P2P is special, and needs a custom protocol
    let p2p_addr: Url = format!("org.internetcomputer.p2p1://{}", parts[2]).parse()?;
    Ok(Node {
        node_index,
        subnet_index,
        config: NodeConfiguration {
            p2p_num_flows: 0,
            p2p_start_flow_tag: 0,
            xnet_api: vec![ConnectionEndpoint::from(xnet_addr)],
            public_api: vec![ConnectionEndpoint::from(http_addr)],
            // TODO(O4-41): Empty, because the replica does not distinguish
            // between them and the --nodes flag doesn't support providing it.
            private_api: vec![],
            prometheus_metrics: vec![ConnectionEndpoint::from(metrics_addr)],
            p2p_addr: ConnectionEndpoint::try_from(p2p_addr)?,
            node_operator_principal_id: None,
        },
    })
}
fn parse_nodes_deprecated ( src : & str ) -> Result < Node > { // We allow for both, the comma (',') and dash ('-'), to be used as separators // of tuple components. The dash ('-') conflicts with using domain names // containing dashes in place of ip addresses. // TODO(RPL-255): The goal is to switch to commas (',') entirely, but we will // remain backwards compatible for the moment. let separator = if src . contains ( ',' ) { ',' } else { '-' } ; let parts = src . splitn ( 6 , separator ) . collect :: < Vec < & str > > ( ) ; let node_index = parts [ 0 ] . parse :: < u64 > ( ) . unwrap ( ) ; let subnet_part = parts [ 1 ] ; let subnet_index = if subnet_part . is_empty ( ) { None } else { Some ( subnet_part . parse :: < u64 > ( ) . unwrap ( ) ) } ; // For most endpoints default to `http` as the protocol, which is consistent // with existing behaviour for this flag. let xnet_addr : SocketAddr = parts [ 3 ] . parse ( ) . with_context ( | | format ! ( " " parts [ 3 ] ) ) ? ; // Default to listening on 0.0.0.0 for metrics (consistent with past // behaviour) let metrics_port = parts [ 4 ] . parse :: < u16 > ( ) . unwrap ( ) ; let metrics_addr : SocketAddr = SocketAddrV4 :: new ( " " . parse ( ) . expect ( " " ) , metrics_port ) . into ( ) ; let http_addr : SocketAddr = parts [ 5 ] . parse ( ) . with_context ( | | format ! ( " " parts [ 3 ] ) ) ? ; // P2P is special, and needs a custom protocol let p2p_addr : Url = format ! ( " " parts [ 2 ] ) . parse ( ) ? ; Ok ( Node { node_index , subnet_index , config : NodeConfiguration { p2p_num_flows : 0 , p2p_start_flow_tag : 0 , xnet_api : vec ! [ ConnectionEndpoint from ( xnet_addr ) ] , public_api : vec ! [ ConnectionEndpoint from ( http_addr ) ] , // TODO(O4-41): Empty, because the replica does not distinguish // between them and the --nodes flag doesn't support providing it. private_api : vec ! [ ] , prometheus_metrics : vec ! [ ConnectionEndpoint from ( metrics_addr ) ] , p2p_addr : ConnectionEndpoint :: try_from ( p2p_addr ) ? , node_operator_principal_id : None , } , } ) }
Parse a --nodes flag value in to a Node.
Parse a -- nodes flag value in to a Node .
src
&str