Skip to content

Commit

Permalink
chore(clippy): make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Sep 21, 2023
1 parent 417fce2 commit d6e457d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "stable-2023-08-03"
channel = "nightly-2023-08-03"
components = ["rustfmt", "clippy"]
profile = "minimal"
19 changes: 9 additions & 10 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ pub trait DBObject: Serialize + for<'de> Deserialize<'de> + Copy {
fn db_key(suffix: Vec<u8>) -> Vec<u8>;

/// Asynchronous methods for getting and setting the object in storage
async fn get<S: Storage>(storage: &S, suffix: &Vec<u8>) -> Option<Self>
async fn get<S: Storage>(storage: &S, suffix: &[u8]) -> Option<Self>
where
Self: Sized,
{
let key = Self::db_key(suffix.clone());
if let Some(data) = storage.get_value(key).await {
Some(from_slice(&data).expect("Failed to deserialize data"))
} else {
None
}
let key = Self::db_key(suffix.to_vec());
storage
.get_value(key)
.await
.map(|data| from_slice(&data).expect("Failed to deserialize data"))
}

async fn set<S: Storage>(&self, storage: &S, suffix: &Vec<u8>) {
let key = Self::db_key(suffix.clone());
async fn set<S: Storage>(&self, storage: &S, suffix: &[u8]) {
let key = Self::db_key(suffix.to_vec());
let data = to_vec(self).expect("Failed to serialize data");
storage.set_value(key, data).await;
}
Expand All @@ -39,7 +38,7 @@ pub trait DBObject: Serialize + for<'de> Deserialize<'de> + Copy {
pub struct FactCheckingContext<S: Storage> {
storage: S,
hash_func: HashFunctionType,
n_workers: Option<u32>,
_n_workers: Option<u32>,
}

pub trait Fact: DBObject {
Expand Down
2 changes: 1 addition & 1 deletion src/storage/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl CommitmentInfo {
let actual_updated_tree = previous_tree
.update(ffc, modifications, Some(&mut commitment_facts))
.await;
let actual_updated_root: FieldElement = actual_updated_tree.root.into();
let actual_updated_root: FieldElement = actual_updated_tree.root;

if actual_updated_root != expected_updated_root {
return Err(CommitmentInfoError::InconsistentTreeRoots(
Expand Down
2 changes: 1 addition & 1 deletion src/utils/commitment_tree/binary_fact_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
index: FieldElement,
) -> Result<L, FactTreeError> {
let leaves = self.get_leaves(ffc, vec![index], None).await;
if leaves.keys().ne(vec![index].iter()) {
if leaves.keys().ne([index].iter()) {
return Err(FactTreeError::UnexpectedResult(index));
}

Expand Down
24 changes: 12 additions & 12 deletions src/utils/commitment_tree/patricia_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@ pub struct PatriciaTree {
}

impl<S: Storage, L: LeafFact> BinaryFactTree<S, L> for PatriciaTree {
async fn empty_tree(&self, ffc: FactCheckingContext<S>, height: usize, leaft_fact: L) {
async fn empty_tree(&self, _ffc: FactCheckingContext<S>, _height: usize, _leaft_fact: L) {
todo!()
}

async fn get_leaves(
&self,
ffc: FactCheckingContext<S>,
indices: Vec<FieldElement>,
facts: Option<BinaryFactDict>,
_ffc: FactCheckingContext<S>,
_indices: Vec<FieldElement>,
_facts: Option<BinaryFactDict>,
) -> HashMap<FieldElement, L> {
todo!()
}

async fn _get_leaves(
&self,
ffc: FactCheckingContext<S>,
indices: Vec<FieldElement>,
facts: Option<BinaryFactDict>,
_ffc: FactCheckingContext<S>,
_indices: Vec<FieldElement>,
_facts: Option<BinaryFactDict>,
) -> HashMap<FieldElement, L> {
todo!()
}

async fn update(
&self,
ffc: FactCheckingContext<S>,
modifications: HashMap<FieldElement, L>,
facts: Option<&mut BinaryFactDict>,
_ffc: FactCheckingContext<S>,
_modifications: HashMap<FieldElement, L>,
_facts: Option<&mut BinaryFactDict>,
) -> Self {
todo!()
}

async fn get_leaf(
&self,
ffc: FactCheckingContext<S>,
index: FieldElement,
_ffc: FactCheckingContext<S>,
_index: FieldElement,
) -> Result<L, FactTreeError> {
todo!()
}
Expand Down

0 comments on commit d6e457d

Please sign in to comment.