Преглед на файлове

net: change unwrap() to expect() on hostlist queries

lunar-mining преди 2 години
родител
ревизия
765bd819b2
променени са 2 файла, в които са добавени 13 реда и са изтрити 4 реда
  1. 12 3
      src/net/hosts/store.rs
  2. 1 1
      src/net/session/mod.rs

+ 12 - 3
src/net/hosts/store.rs

@@ -291,7 +291,10 @@ impl Hosts {
                 debug!(target: "store::greylist_store_or_update()",
                 debug!(target: "store::greylist_store_or_update()",
                 "We have this entry in the greylist. Updating last seen...");
                 "We have this entry in the greylist. Updating last seen...");
 
 
-                let index = self.get_greylist_index_at_addr(addr.clone()).await.unwrap();
+                let index = self
+                    .get_greylist_index_at_addr(addr.clone())
+                    .await
+                    .expect("Expected greylist entry to exist");
                 self.greylist_update_last_seen(&addr, last_seen, index).await;
                 self.greylist_update_last_seen(&addr, last_seen, index).await;
             }
             }
         }
         }
@@ -315,7 +318,10 @@ impl Hosts {
                 debug!(target: "store::whitelist_store_or_update()",
                 debug!(target: "store::whitelist_store_or_update()",
         "We have this entry in the whitelist. Updating last seen...");
         "We have this entry in the whitelist. Updating last seen...");
 
 
-                let index = self.get_whitelist_index_at_addr(addr.clone()).await.unwrap();
+                let index = self
+                    .get_whitelist_index_at_addr(addr.clone())
+                    .await
+                    .expect("Expected whitelist entry to exist");
                 self.whitelist_update_last_seen(addr, last_seen.clone(), index).await;
                 self.whitelist_update_last_seen(addr, last_seen.clone(), index).await;
             }
             }
         }
         }
@@ -338,7 +344,10 @@ impl Hosts {
                 debug!(target: "store::anchorlist_store_or_update()",
                 debug!(target: "store::anchorlist_store_or_update()",
         "We have this entry in the anchorlist. Updating last seen...");
         "We have this entry in the anchorlist. Updating last seen...");
 
 
-                let index = self.get_anchorlist_index_at_addr(addr.clone()).await.unwrap();
+                let index = self
+                    .get_anchorlist_index_at_addr(addr.clone())
+                    .await
+                    .expect("Expected anchorlist entry to exist");
                 self.anchorlist_update_last_seen(addr, last_seen.clone(), index).await;
                 self.anchorlist_update_last_seen(addr, last_seen.clone(), index).await;
             }
             }
         }
         }

+ 1 - 1
src/net/session/mod.rs

@@ -22,7 +22,7 @@ use std::{
 };
 };
 
 
 use async_trait::async_trait;
 use async_trait::async_trait;
-use log::{debug};
+use log::debug;
 use smol::Executor;
 use smol::Executor;
 
 
 use super::{channel::ChannelPtr, p2p::P2pPtr, protocol::ProtocolVersion};
 use super::{channel::ChannelPtr, p2p::P2pPtr, protocol::ProtocolVersion};