From 5dac9c797afbd52485f0ee02d5f3d89573712990 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Fri, 22 Mar 2024 00:38:04 +0200 Subject: [PATCH] removed some warnings --- p2p-net/src/broker.rs | 2 +- p2p-net/src/tests/file.rs | 2 +- stores-rocksdb/src/kcv_store.rs | 30 ++++++++++++------------------ 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/p2p-net/src/broker.rs b/p2p-net/src/broker.rs index d7a9981..de89005 100644 --- a/p2p-net/src/broker.rs +++ b/p2p-net/src/broker.rs @@ -297,7 +297,7 @@ impl<'a> Broker<'a> { // .read_to_end(&mut block_buffer) // .expect("read of test.ng"); - let block = serde_bare::from_slice::(&crate::tests::file::test).unwrap(); + let block = serde_bare::from_slice::(&crate::tests::file::TEST).unwrap(); tx.send(block).await; Ok(rx) diff --git a/p2p-net/src/tests/file.rs b/p2p-net/src/tests/file.rs index 78ca9fb..ebfd4a2 100644 --- a/p2p-net/src/tests/file.rs +++ b/p2p-net/src/tests/file.rs @@ -1,4 +1,4 @@ -pub const test: [u8; 29487] = [ +pub const TEST: [u8; 29487] = [ 0, 0, 0, 0, 1, 0, 0, 0, 128, 163, 230, 1, 94, 122, 113, 30, 147, 252, 87, 146, 193, 199, 154, 156, 116, 48, 90, 60, 132, 44, 212, 181, 100, 82, 138, 212, 5, 164, 60, 61, 164, 83, 216, 88, 3, 20, 128, 34, 22, 228, 163, 35, 113, 184, 99, 134, 170, 154, 0, 227, 0, 173, 138, 120, 9, 50, diff --git a/stores-rocksdb/src/kcv_store.rs b/stores-rocksdb/src/kcv_store.rs index 743ad39..b97918a 100644 --- a/stores-rocksdb/src/kcv_store.rs +++ b/stores-rocksdb/src/kcv_store.rs @@ -9,18 +9,11 @@ use p2p_repo::kcv_store::*; use p2p_repo::store::*; -use p2p_repo::types::*; -use p2p_repo::utils::*; use p2p_repo::log::*; use std::path::Path; use std::path::PathBuf; -use std::sync::RwLockReadGuard; -use std::sync::{Arc, RwLock}; - -use serde::{Deserialize, Serialize}; -use serde_bare::error::Error; use rocksdb::{ ColumnFamilyDescriptor, Direction, Env, ErrorKind, IteratorMode, Options, SingleThreaded, @@ -56,10 +49,10 @@ impl<'a> ReadTransaction for RocksdbTransaction<'a> { /// Load a single value property from the store. fn get(&self, prefix: u8, key: &Vec, suffix: Option) -> Result, StorageError> { let property = RocksdbKCVStore::compute_property(prefix, key, suffix); - let mut res = self + let res = self .tx() .get_for_update(property, true) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; match res { Some(val) => Ok(val), None => Err(StorageError::NotFound), @@ -88,7 +81,7 @@ impl<'a> ReadTransaction for RocksdbTransaction<'a> { let exists = self .tx() .get_for_update(property, true) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; match exists { Some(stored_value) => { if stored_value.eq(value) { @@ -114,7 +107,7 @@ impl<'a> WriteTransaction for RocksdbTransaction<'a> { let property = RocksdbKCVStore::compute_property(prefix, key, suffix); self.tx() .put(property, value) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; Ok(()) } @@ -131,7 +124,7 @@ impl<'a> WriteTransaction for RocksdbTransaction<'a> { self.tx() .put(property, value) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; Ok(()) } @@ -161,13 +154,13 @@ impl<'a> WriteTransaction for RocksdbTransaction<'a> { let exists = self .tx() .get_for_update(property.clone(), true) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; match exists { Some(val) => { if val.eq(value) { self.tx() .delete(property) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; } } None => return Err(StorageError::DifferentValue), @@ -241,7 +234,8 @@ impl ReadTransaction for RocksdbKCVStore { .main_db .iterator(IteratorMode::From(&property_start, Direction::Forward)); let mut vector: Vec<(Vec, Vec)> = vec![]; - while let res = iter.next() { + loop { + let res = iter.next(); match res { Some(Ok(val)) => { match compare(&val.0, property_end.as_slice()) { @@ -272,10 +266,10 @@ impl ReadTransaction for RocksdbKCVStore { /// Load a single value property from the store. fn get(&self, prefix: u8, key: &Vec, suffix: Option) -> Result, StorageError> { let property = Self::compute_property(prefix, key, suffix); - let mut res = self + let res = self .main_db .get(property) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; match res { Some(val) => Ok(val), None => Err(StorageError::NotFound), @@ -304,7 +298,7 @@ impl ReadTransaction for RocksdbKCVStore { let exists = self .main_db .get(property) - .map_err(|e| StorageError::BackendError)?; + .map_err(|_e| StorageError::BackendError)?; match exists { Some(stored_value) => { if stored_value.eq(value) {