// Generates the config and the registry node records for the three nodes
// Returns a map of NodeId -> (TransportConfig, NodeRecord)
// TODO: P2P-517 read from a config file
Generates the config and the registry node records for the three nodes
Returns a map of NodeId -> (TransportConfig, NodeRecord)
TODO: P2P-517 read from a config file
Generates the config and the registry node records for the three nodes Returns a map of NodeId - > ( TransportConfig NodeRecord ) TODO : P2P - 517 read from a config file
fn generate_config_and_registry(node_id: &NodeId) -> ConfigAndRecords {
    // Tuples: (NodeId, IP, server port 1, server port 2)
    let node_info = vec![
        (to_node_id(1), "127.0.0.1".to_string(), 4100, 4101),
        (to_node_id(2), "127.0.0.1".to_string(), 4102, 4103),
        (to_node_id(3), "127.0.0.1".to_string(), 4104, 4105),
    ];
    let mut config = None;
    let mut node_records = Vec::new();
    for n in node_info.iter() {
        if *node_id == n.0 {
            config = Some(TransportConfig {
                node_ip: n.1.clone(),
                p2p_flows: vec![
                    TransportFlowConfig {
                        flow_tag: FLOW_TAG_1,
                        server_port: n.2,
                        queue_size: 1024,
                    },
                    TransportFlowConfig {
                        flow_tag: FLOW_TAG_2,
                        server_port: n.3,
                        queue_size: 1024,
                    },
                ],
            });
        }
        let mut node_record: NodeRecord = Default::default();
        node_record.p2p_flow_endpoints.push(FlowEndpoint {
            flow_tag: FLOW_TAG_1,
            endpoint: Some(ConnectionEndpoint {
                ip_addr: n.1.clone(),
                port: n.2 as u32,
                protocol: Protocol::P2p1Tls13 as i32,
            }),
        });
        node_record.p2p_flow_endpoints.push(FlowEndpoint {
            flow_tag: FLOW_TAG_2,
            endpoint: Some(ConnectionEndpoint {
                ip_addr: n.1.clone(),
                port: n.3 as u32,
                protocol: Protocol::P2p1Tls13 as i32,
            }),
        });
        node_records.push((n.0, node_record));
    }
    ConfigAndRecords {
        config: config.unwrap(),
        node_records,
    }
}
fn generate_config_and_registry ( node_id : & NodeId ) -> ConfigAndRecords { // Tuples: (NodeId, IP, server port 1, server port 2) let node_info = vec ! [ ( to_node_id ( 1 ) " " to_string ( ) 4100 4101 ) ( to_node_id ( 2 ) " " to_string ( ) 4102 4103 ) ( to_node_id ( 3 ) " " to_string ( ) 4104 4105 ) ] ; let mut config = None ; let mut node_records = Vec :: new ( ) ; for n in node_info . iter ( ) { if * node_id == n . 0 { config = Some ( TransportConfig { node_ip : n . 1 . clone ( ) , p2p_flows : vec ! [ TransportFlowConfig { flow_tag FLOW_TAG_1 server_port n 2 queue_size 1024 } TransportFlowConfig { flow_tag FLOW_TAG_2 server_port n 3 queue_size 1024 } ] , } ) ; } let mut node_record : NodeRecord = Default :: default ( ) ; node_record . p2p_flow_endpoints . push ( FlowEndpoint { flow_tag : FLOW_TAG_1 , endpoint : Some ( ConnectionEndpoint { ip_addr : n . 1 . clone ( ) , port : n . 2 as u32 , protocol : Protocol :: P2p1Tls13 as i32 , } ) , } ) ; node_record . p2p_flow_endpoints . push ( FlowEndpoint { flow_tag : FLOW_TAG_2 , endpoint : Some ( ConnectionEndpoint { ip_addr : n . 1 . clone ( ) , port : n . 3 as u32 , protocol : Protocol :: P2p1Tls13 as i32 , } ) , } ) ; node_records . push ( ( n . 0 , node_record ) ) ; } ConfigAndRecords { config : config . unwrap ( ) , node_records , } }
Generates the config and the registry node records for the three nodes
Returns a map of NodeId -> (TransportConfig, NodeRecord)
TODO: P2P-517 read from a config file
Generates the config and the registry node records for the three nodes Returns a map of NodeId - > ( TransportConfig NodeRecord ) TODO : P2P - 517 read from a config file
node_id
&NodeId