Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Nov 13, 2024
1 parent d60c5ef commit b376ff3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions crates/chia-datalayer/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ impl Node {
pub fn from_bytes(metadata: &NodeMetadata, blob: &DataBytes) -> Result<Self, Error> {
Ok(match metadata.node_type {
NodeType::Internal => Node::Internal(
Streamable::from_bytes_ignore_extra_bytes(blob).map_err(|e| Error::Streaming(e))?,
Streamable::from_bytes_ignore_extra_bytes(blob).map_err(Error::Streaming)?,
),
NodeType::Leaf => Node::Leaf(
Streamable::from_bytes_ignore_extra_bytes(blob).map_err(|e| Error::Streaming(e))?,
Streamable::from_bytes_ignore_extra_bytes(blob).map_err(Error::Streaming)?,
),
})
}
Expand All @@ -269,10 +269,9 @@ impl Node {
Node::Internal(node) => node.to_bytes(),
Node::Leaf(node) => node.to_bytes(),
}
.map_err(|e| Error::Streaming(e))?;
for _ in base.len()..DATA_SIZE {
base.push(0);
}
.map_err(Error::Streaming)?;
assert!(base.len() <= DATA_SIZE);
base.resize(DATA_SIZE, 0);
Ok(base
.as_slice()
.try_into()
Expand Down Expand Up @@ -319,8 +318,7 @@ pub struct Block {
impl Block {
pub fn to_bytes(&self) -> Result<BlockBytes, Error> {
let mut blob: BlockBytes = [0; BLOCK_SIZE];
blob[METADATA_RANGE]
.copy_from_slice(&self.metadata.to_bytes().map_err(|e| Error::Streaming(e))?);
blob[METADATA_RANGE].copy_from_slice(&self.metadata.to_bytes().map_err(Error::Streaming)?);
blob[DATA_RANGE].copy_from_slice(&self.node.to_bytes()?);

Ok(blob)
Expand Down

0 comments on commit b376ff3

Please sign in to comment.