Function sc_network_common::config::parse_str_addr
source · pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr>
Expand description
Parses a string address and splits it into Multiaddress and PeerId, if valid.
Example
let (peer_id, addr) = parse_str_addr(
"/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"
).unwrap();
assert_eq!(peer_id, "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".parse::<PeerId>().unwrap());
assert_eq!(addr, "/ip4/198.51.100.19/tcp/30333".parse::<Multiaddr>().unwrap());