Skip to content

Commit

Permalink
chore: a few random corrections and additions found while reading code
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdplm committed Oct 25, 2023
1 parent e9ec4ec commit b09efe0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ authors = ["Polygon Zero <[email protected]>"]
edition = "2021"
readme = "README.md"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/mir-protocol/eth-trie-utils"
repository = "https://github.com/mir-protocol/eth-trie-utils"
homepage = "https://github.com/0xPolygonZero/eth-trie-utils"
repository = "https://github.com/0xPolygonZero/eth-trie-utils"
keywords = ["ethereum", "trie"]
categories = ["cryptography::cryptocurrencies", "data-structures"]

Expand Down
10 changes: 5 additions & 5 deletions examples/hash_nodes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Example showing how to use `Hash` nodes.
//!
//!`Hash` nodes are used when you want to only want to represent part of a
//!`Hash` nodes are used when you want to only represent part of a
//! larger trie but still want the generated hashes to be the same as the larger
//! trie. `Hash` nodes contain the merkle hash of the nodes of they replace.
//! trie. `Hash` nodes contain the merkle hash of the nodes they replace.
//!
//! For example, say you want to generate a proof for a trie. The proof
//! itself only needs a very small subset of the values in the trie. However,
Expand Down Expand Up @@ -41,9 +41,9 @@
//! they are 16-ary.
//!
//! Finally, at least for the time being, it is assumed that if you are
//! converting a large partial trie into a `PartialTrie` then you are able to
//! calculate the hashes for the nodes you want to remove from the trie without
//! using this library.
//! converting a large partial trie into a smaller `PartialTrie` then you are
//! able to calculate the hashes for the nodes you want to remove from the trie
//! without using this library.
use std::{
iter::{once, repeat},
Expand Down
8 changes: 6 additions & 2 deletions src/trie_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl InsertEntry {
}
}

/// A "entry" in a [`PartialTrie`].
///
/// An "entry" in a [`PartialTrie`].
///
/// Entries in the trie may either be actual values or
/// [`Hash`](crate::partial_trie::Node::Hash) nodes.
#[derive(Clone, Debug, EnumAsInner, Eq, Hash, PartialEq)]
Expand Down Expand Up @@ -105,11 +105,15 @@ impl_prim_int_from_for_val_variant!(u16);
impl_prim_int_from_for_val_variant!(u8);

impl ValOrHash {
/// Cast a [`ValOrHash::Hash`] enum to the hash ([`H256`]). Panics if called
/// on the wrong enum variant.
pub fn expect_hash(self) -> H256 {
self.into_hash()
.expect("Expected a `ValOrHash` to be a hash")
}

/// Cast a [`ValOrHash::Val`] enum to the value ([`Vec<u8>`]). Panics if
/// called on the wrong enum variant.
pub fn expect_val(self) -> Vec<u8> {
self.into_val()
.expect("Expected a `ValOrHash` to be a value")
Expand Down

0 comments on commit b09efe0

Please sign in to comment.