/// Parses the seed peers from a delimited string into a list of peers
/// ## Parameters
/// `seeds` - A string of peers delimited by '::'
///
/// ## Returns
/// A list of peers, peers which do not have a valid public key are excluded
Parses the seed peers from a delimited string into a list of peers
Parses the seed peers from a delimited string into a list of peers
pub fn parse_peer_seeds(seeds: &[String]) -> Vec<Peer> {
    info!("Adding {} peers to the peer database", seeds.len());
    let mut result = Vec::with_capacity(seeds.len());
    for s in seeds {
        let parts: Vec<&str> = s.split("::").map(|s| s.trim()).collect();
        if parts.len() != 2 {
            warn!(target: LOG_TARGET, "Invalid peer seed: {}", s);
            continue;
        }
        let pub_key = match PublicKey::from_hex(parts[0]) {
            Err(e) => {
                warn!(
                    target: LOG_TARGET,
                    "{} is not a valid peer seed. The public key is incorrect. {}",
                    s,
                    e.to_string()
                );
                continue;
            },
            Ok(p) => p,
        };
        let addr = match parts[1].parse::<Multiaddr>() {
            Err(e) => {
                warn!(
                    target: LOG_TARGET,
                    "{} is not a valid peer seed. The address is incorrect. {}",
                    s,
                    e.to_string()
                );
                continue;
            },
            Ok(a) => a,
        };
        let node_id = match NodeId::from_key(&pub_key) {
            Err(e) => {
                warn!(
                    target: LOG_TARGET,
                    "{} is not a valid peer seed. A node id couldn't be derived from the public key. {}",
                    s,
                    e.to_string()
                );
                continue;
            },
            Ok(id) => id,
        };
        let peer = Peer::new(
            pub_key,
            node_id,
            addr.into(),
            PeerFlags::default(),
            PeerFeatures::COMMUNICATION_NODE,
            &[],
            Default::default(),
        );
        result.push(peer);
    }
    result
}
pub fn parse_peer_seeds ( seeds : & [ String ] ) -> Vec < Peer > { info ! ( " " seeds len ( ) ) ; let mut result = Vec :: with_capacity ( seeds . len ( ) ) ; for s in seeds { let parts : Vec < & str > = s . split ( " " ) . map ( | s | s . trim ( ) ) . collect ( ) ; if parts . len ( ) != 2 { warn ! ( target LOG_TARGET " " s ) ; continue ; } let pub_key = match PublicKey :: from_hex ( parts [ 0 ] ) { Err ( e ) => { warn ! ( target LOG_TARGET " " s e to_string ( ) ) ; continue ; } , Ok ( p ) => p , } ; let addr = match parts [ 1 ] . parse :: < Multiaddr > ( ) { Err ( e ) => { warn ! ( target LOG_TARGET " " s e to_string ( ) ) ; continue ; } , Ok ( a ) => a , } ; let node_id = match NodeId :: from_key ( & pub_key ) { Err ( e ) => { warn ! ( target LOG_TARGET " " s e to_string ( ) ) ; continue ; } , Ok ( id ) => id , } ; let peer = Peer :: new ( pub_key , node_id , addr . into ( ) , PeerFlags :: default ( ) , PeerFeatures :: COMMUNICATION_NODE , & [ ] , Default :: default ( ) , ) ; result . push ( peer ) ; } result }
Parses the seed peers from a delimited string into a list of peers
Parses the seed peers from a delimited string into a list of peers
A list of peers, peers which do not have a valid public key are excluded
A list of peers peers which do not have a valid public key are excluded
seeds
&[String]