Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive the standard Error trait using the thiserror crate #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tree_hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ categories = ["cryptography::cryptocurrencies"]
ethereum-types = "0.14.1"
ethereum_hashing = "0.6.0"
smallvec = "1.6.1"
thiserror = "1.0.58"

[dev-dependencies]
rand = "0.8.5"
Expand Down
4 changes: 3 additions & 1 deletion tree_hash/src/merkle_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ use crate::{get_zero_hash, Hash256, HASHSIZE};
use ethereum_hashing::{Context, Sha256Context, HASH_LEN};
use smallvec::{smallvec, SmallVec};
use std::mem;
use thiserror::Error;

type SmallVec8<T> = SmallVec<[T; 8]>;

#[derive(Clone, Debug, PartialEq)]
#[derive(Error, Clone, Debug, PartialEq)]
pub enum Error {
/// The maximum number of leaves defined by the initialization `depth` has been exceed.
#[error("The maximum number of leaves {max_leaves} has beed exceed.")]
MaximumLeavesExceeded { max_leaves: usize },
}

Expand Down