skoupidi před 2 týdny
rodič
revize
8f16456cbc

+ 1 - 1
bin/fud/fud/src/dht.rs

@@ -221,7 +221,7 @@ impl DhtHandler for Fud {
                 if cached.node_id != node.id() {
                     self.dht.remove_node(&cached.node_id).await;
 
-                    for (_, seeders) in self.dht.hash_table.write().await.iter_mut() {
+                    for seeders in self.dht.hash_table.write().await.values_mut() {
                         seeders.retain(|seeder| seeder.node.id() != cached.node_id);
                     }
                 }

+ 1 - 1
bin/fud/fud/src/lib.rs

@@ -505,7 +505,7 @@ impl Fud {
         };
 
         let mut seeding_resources: Vec<Resource> = vec![];
-        for (_, mut resource) in resources_write.iter_mut() {
+        for mut resource in resources_write.values_mut() {
             if let Some(ref hashes_list) = hashes {
                 if !hashes_list.contains(&resource.hash) {
                     continue;

+ 1 - 1
bin/fud/fud/src/rpc/mod.rs

@@ -205,7 +205,7 @@ impl DefaultRpcInterface {
 
         let resources_read = self.fud.resources.read().await;
         let mut resources: Vec<JsonValue> = vec![];
-        for (_, resource) in resources_read.iter() {
+        for resource in resources_read.values() {
             resources.push(resource.clone().into());
         }
 

+ 1 - 1
bin/zkas/src/main.rs

@@ -161,7 +161,7 @@ fn main() -> ExitCode {
         return ExitCode::FAILURE
     };
 
-    println!("Wrote output to {}", &output);
+    println!("Wrote output to {output}");
 
     if eflag {
         let zkbin = ZkBinary::decode(&bincode, true).unwrap();

+ 5 - 3
src/event_graph/mod.rs

@@ -560,6 +560,7 @@ pub struct RangeSyncPage {
 /// must belong to the outstanding request. Returned events and blobs are
 /// reordered to match the request order, and missing IDs are returned for
 /// retry with another peer.
+#[allow(clippy::type_complexity)]
 pub(crate) fn filter_requested_event_rep(
     requested: &[blake3::Hash],
     events: Vec<Event>,
@@ -1914,6 +1915,7 @@ impl EventGraph {
         Ok((events, blobs, next_cursor, exhausted))
     }
 
+    #[allow(clippy::too_many_arguments)]
     async fn accept_range_page(
         &self,
         dag_ts: u64,
@@ -2615,7 +2617,7 @@ impl EventGraph {
     }
 
     pub async fn fetch_event_from_dags(&self, eid: &blake3::Hash) -> Result<Option<Event>> {
-        for (_, slot) in self.dag_store.read().await.dags.iter() {
+        for slot in self.dag_store.read().await.dags.values() {
             if let Some(b) = slot.main_tree.get(eid.as_bytes())? {
                 return Ok(Some(deserialize_async(&b).await?))
             }
@@ -2653,7 +2655,7 @@ impl EventGraph {
 
     pub async fn order_events(&self) -> Result<Vec<Event>> {
         let mut all = vec![];
-        for (_, slot) in self.dag_store.read().await.dags.iter() {
+        for slot in self.dag_store.read().await.dags.values() {
             for item in slot.main_tree.iter() {
                 let (_, b) = item?;
                 let ev: Event = deserialize_async(&b).await?;
@@ -3196,7 +3198,7 @@ impl EventGraph {
         let mut dag = HashMap::new();
 
         // Walk every rotating DAG.
-        for (_, slot) in self.dag_store.read().await.dags.iter() {
+        for slot in self.dag_store.read().await.dags.values() {
             for item in slot.main_tree.iter() {
                 let (eid, val) = match item {
                     Ok(v) => v,

+ 2 - 4
src/rpc/common.rs

@@ -53,8 +53,7 @@ pub(super) async fn http_read_from_stream_request(
                 // In HTTP, when we reach '\r\n\r\n' we know we've read the headers.
                 // The rest is the body. Headers should contain Content-Length which
                 // tells us the remaining amount of bytes to read.
-                if total_read > 4 && buf[total_read - 4..total_read] == [b'\r', b'\n', b'\r', b'\n']
-                {
+                if total_read > 4 && buf[total_read - 4..total_read] == *b"\r\n\r\n" {
                     break
                 }
             }
@@ -126,8 +125,7 @@ pub(super) async fn http_read_from_stream_response(
                 // In HTTP, when we reach '\r\n\r\n' we know we've read the headers.
                 // The rest is the body. Headers should contain Content-Length which
                 // tells us the remaining amount of bytes to read.
-                if total_read > 4 && buf[total_read - 4..total_read] == [b'\r', b'\n', b'\r', b'\n']
-                {
+                if total_read > 4 && buf[total_read - 4..total_read] == *b"\r\n\r\n" {
                     break
                 }
             }

+ 2 - 2
src/sdk/python/src/contract/deployooor/deploy_v1.rs

@@ -40,8 +40,8 @@ impl FunctionParams for deploy::DeployParamsV1 {
     fn fmt_pretty(&self, out: &mut String, depth: usize) -> PyResult<()> {
         let prefix = format!("{}├─ ", "   ".repeat(depth));
         writeln!(out, "{prefix}public_key: {}", self.public_key).unwrap();
-        writeln!(out, "{prefix}wasm_bincode: [{} bytes]", &self.wasm_bincode.len()).unwrap();
-        writeln!(out, "{prefix}ix: [{} bytes]", &self.ix.len()).unwrap();
+        writeln!(out, "{prefix}wasm_bincode: [{} bytes]", self.wasm_bincode.len()).unwrap();
+        writeln!(out, "{prefix}ix: [{} bytes]", self.ix.len()).unwrap();
         Ok(())
     }
 }

+ 1 - 1
src/util/path.rs

@@ -40,7 +40,7 @@ mod home_dir_impl {
     /// Use `$HOME`, fallbacks to `libc::getpwuid_r`, otherwise `None`.
     pub fn home_dir() -> Option<PathBuf> {
         env::var_os("HOME")
-            .and_then(|h| if h.is_empty() { None } else { Some(h) })
+            .filter(|h| !h.is_empty())
             .or_else(|| unsafe { home_fallback() })
             .map(PathBuf::from)
     }

+ 1 - 1
src/zkas/analyzer.rs

@@ -609,7 +609,7 @@ impl Analyzer {
             }
             match i.typ {
                 StatementType::Assign => {
-                    println!("Pushing result as `{}` to heap", &i.lhs.as_ref().unwrap().name);
+                    println!("Pushing result as `{}` to heap", i.lhs.as_ref().unwrap().name);
                     heap.push(&i.lhs.as_ref().unwrap().name);
                     println!("Heap:\n{heap:#?}\n-----");
                 }

+ 1 - 1
src/zkas/parser.rs

@@ -490,7 +490,7 @@ impl Parser {
                 return Err(self.error.abort(
                     &format!(
                         "Section `{section_name}` already contains the token `{}`.",
-                        &name.token
+                        name.token
                     ),
                     name.line,
                     name.column,