File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed
Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -75,12 +75,11 @@ impl Default for AppConfig {
7575impl AppConfig {
7676 /// Load configuration from file or create default
7777 pub fn load_or_default ( config_path : Option < & str > ) -> Self {
78- if let Some ( path) = config_path {
79- if let Ok ( content) = std:: fs:: read_to_string ( path) {
80- if let Ok ( config) = serde_json:: from_str ( & content) {
81- return config;
82- }
83- }
78+ if let Some ( config) = config_path
79+ . and_then ( |path| std:: fs:: read_to_string ( path) . ok ( ) )
80+ . and_then ( |content| serde_json:: from_str ( & content) . ok ( ) )
81+ {
82+ return config;
8483 }
8584 Self :: default ( )
8685 }
Original file line number Diff line number Diff line change @@ -146,8 +146,8 @@ impl LibP2pNetworkService {
146146 "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ" ,
147147 ] ;
148148
149- for addr in & bootstrap_peers {
150- if let Ok ( addr) = addr . parse :: < Multiaddr > ( ) {
149+ for addr_str in & bootstrap_peers {
150+ if let Ok ( addr) = addr_str . parse :: < Multiaddr > ( ) {
151151 if let Some ( peer_id) = addr. iter ( ) . find_map ( |p| {
152152 if let libp2p:: multiaddr:: Protocol :: P2p ( peer_id) = p {
153153 Some ( peer_id)
@@ -234,12 +234,12 @@ impl LibP2pNetworkService {
234234 // Trigger Kademlia bootstrap once we start listening
235235 if !bootstrap_attempted {
236236 if let SwarmEvent :: NewListenAddr { .. } = event {
237- if let Err ( e) = swarm. behaviour_mut( ) . kademlia. bootstrap( ) {
238- warn!( "Kademlia bootstrap failed: {:?}" , e) ;
239- } else {
240- info!( "Kademlia bootstrap initiated successfully" ) ;
241- bootstrap_attempted = true ;
242- }
237+ if let Err ( e) = swarm. behaviour_mut( ) . kademlia. bootstrap( ) {
238+ warn!( "Kademlia bootstrap failed: {:?}" , e) ;
239+ } else {
240+ info!( "Kademlia bootstrap initiated successfully" ) ;
241+ bootstrap_attempted = true ;
242+ }
243243 }
244244 }
245245
You can’t perform that action at this time.
0 commit comments