Skip to content

Commit

Permalink
clippy and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Sep 17, 2024
1 parent e5a916e commit d6a1992
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions crates/chia-datalayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl DotLines {
nodes: vec![],
connections: vec![],
pair_boxes: vec![],
note: "".to_string(),
note: String::new(),
}
}

Expand All @@ -105,7 +105,7 @@ impl DotLines {
pub fn dump(&mut self) -> String {
// TODO: consuming itself, secretly
let note = &self.note;
let mut result = vec![format!("# {note}"), "".to_string(), "digraph {".to_string()];
let mut result = vec![format!("# {note}"), String::new(), "digraph {".to_string()];
result.append(&mut self.nodes);
result.append(&mut self.connections);
result.append(&mut self.pair_boxes);
Expand Down Expand Up @@ -312,7 +312,7 @@ impl Node {
pair_boxes: vec![
format!("node [shape = box]; {{rank = same; node_{left}->node_{right}[style=invis]; rankdir = LR}}"),
],
note: "".to_string(),
note: String::new(),
},
NodeSpecific::Leaf {key_value} => DotLines{
nodes: vec![
Expand All @@ -326,7 +326,7 @@ impl Node {
},
],
pair_boxes: vec![],
note: "".to_string(),
note: String::new(),
},
}
}
Expand Down Expand Up @@ -466,19 +466,20 @@ impl MerkleBlob {
// TODO: what about only unused providing a blob length?
if self.blob.is_empty() {
self.insert_first(key_value, hash);
return Ok(());
}

// TODO: make this a parameter so we have one insert call where you specify the location
let old_leaf = self.get_random_leaf_node_from_bytes(Vec::from(key_value.to_be_bytes()))?;
let internal_node_hash = internal_hash(&old_leaf.hash, hash);
} else {
// TODO: make this a parameter so we have one insert call where you specify the location
let old_leaf =
self.get_random_leaf_node_from_bytes(Vec::from(key_value.to_be_bytes()))?;
let internal_node_hash = internal_hash(&old_leaf.hash, hash);

if self.kv_to_index.len() == 1 {
self.insert_second(key_value, hash, &old_leaf, &internal_node_hash);
return Ok(());
if self.kv_to_index.len() == 1 {
self.insert_second(key_value, hash, &old_leaf, &internal_node_hash);
} else {
self.insert_third_or_later(key_value, hash, &old_leaf, &internal_node_hash)?;
}
}

self.insert_third_or_later(key_value, hash, &old_leaf, &internal_node_hash)
Ok(())
}

fn insert_first(&mut self, key_value: KvId, hash: &Hash) {
Expand Down

0 comments on commit d6a1992

Please sign in to comment.