Skip to content

Commit

Permalink
fix decoding and clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev committed Mar 25, 2024
1 parent 90f5fc5 commit a516fb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
8 changes: 0 additions & 8 deletions merkle_old/proptest-regressions/mpt.txt

This file was deleted.

3 changes: 0 additions & 3 deletions merkle_old/src/nodes/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ pub(crate) enum RlpStructure {

impl Decodable for RlpStructure {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
if buf[0] < EMPTY_STRING_CODE {
return Ok(Self::Value(buf.copy_to_bytes(1)));
}
let header = Header::decode(buf)?;

if header.list {
Expand Down
17 changes: 10 additions & 7 deletions merkle_old/src/nodes/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::{keccak256, B256};
use alloy_rlp::{Decodable, Encodable, EMPTY_STRING_CODE};
use alloy_rlp::{Decodable, Encodable};
use anyhow::{bail, Result};
use bytes::Bytes;
use db::Db;
Expand Down Expand Up @@ -46,12 +46,15 @@ impl Encodable for Node {

impl Decodable for Node {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
if buf[0] == EMPTY_STRING_CODE {
return Ok(Node::Nil);
}

let RlpStructure::List(payloads) = RlpStructure::decode(buf)? else {
return Err(alloy_rlp::Error::UnexpectedString);
let payloads = match RlpStructure::decode(buf)? {
RlpStructure::List(payloads) => payloads,
RlpStructure::Value(value) => {
return if value.is_empty() {
Ok(Node::Nil)
} else {
Err(alloy_rlp::Error::UnexpectedString)
};
}
};
match payloads.len() {
2 => {
Expand Down

0 comments on commit a516fb0

Please sign in to comment.