Return errors instead of panic in libp2p
This commit is contained in:
		
							parent
							
								
									e550c0218f
								
							
						
					
					
						commit
						059699736b
					
				| @ -57,7 +57,10 @@ impl Service { | ||||
|         }; | ||||
| 
 | ||||
|         // listen on all addresses
 | ||||
|         for address in config.listen_addresses().expect("invalid listen multiaddr") { | ||||
|         for address in config | ||||
|             .listen_addresses() | ||||
|             .map_err(|e| format!("Invalid listen multiaddr: {}", e))? | ||||
|         { | ||||
|             match Swarm::listen_on(&mut swarm, address.clone()) { | ||||
|                 Ok(mut listen_addr) => { | ||||
|                     listen_addr.append(Protocol::P2p(local_peer_id.clone().into())); | ||||
| @ -68,7 +71,10 @@ impl Service { | ||||
|         } | ||||
|         // connect to boot nodes - these are currently stored as multiaddrs
 | ||||
|         // Once we have discovery, can set to peerId
 | ||||
|         for bootnode in config.boot_nodes().expect("invalid boot node multiaddr") { | ||||
|         for bootnode in config | ||||
|             .boot_nodes() | ||||
|             .map_err(|e| format!("Invalid boot node multiaddr: {:?}", e))? | ||||
|         { | ||||
|             match Swarm::dial_addr(&mut swarm, bootnode.clone()) { | ||||
|                 Ok(()) => debug!(log, "Dialing bootnode: {}", bootnode), | ||||
|                 Err(err) => debug!( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user