Skip to content

Commit

Permalink
fix and improve hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhmelody committed Dec 22, 2023
1 parent a1bfbe1 commit 459915f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ derive_more = "0.99"
nybbles = { version = "0.1", default-features = false }
smallvec = "1.11"
tracing = { version = "0.1", default-features = false }
hashbrown = { version = "0.14" }
hashbrown = { version = "0.14", features = ["serde", "ahash", "inline-more"] }
# serde
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }

Expand All @@ -33,7 +33,7 @@ proptest = { version = "1.4", optional = true }
proptest-derive = { version = "0.4", optional = true }

[dev-dependencies]
hash-db = "0.16"
hash-db = "0.15"
plain_hasher = "0.2"
triehash = "0.8.4"

Expand Down
8 changes: 3 additions & 5 deletions src/hash_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use super::{
};
use alloy_primitives::{keccak256, Bytes, B256};
use core::cmp;
#[cfg(not(feature = "std"))]
use hashbrown::HashMap;
#[cfg(feature = "std")]
use std::collections::HashMap;
use std::{collections::BTreeMap, fmt::Debug, format, vec, vec::Vec};
use tracing::trace;

Expand Down Expand Up @@ -422,7 +419,8 @@ mod tests {
use super::*;
use alloy_primitives::{b256, hex, keccak256, B256, U256};
use alloy_rlp::Encodable;
use std::collections::{BTreeMap, HashMap};
use hashbrown::HashMap;
use std::collections::BTreeMap;

fn triehash_trie_root<I, K, V>(iter: I) -> B256
where
Expand Down Expand Up @@ -577,7 +575,7 @@ mod tests {

#[test]
fn test_root_rlp_hashed_data() {
let data = HashMap::from([
let data: HashMap<_, _, _> = HashMap::from([
(B256::with_last_byte(1), U256::from(2)),
(B256::with_last_byte(3), U256::from(4)),
]);
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub use hash_builder::HashBuilder;
mod mask;
pub use mask::TrieMask;

pub use hashbrown::HashMap;

#[doc(no_inline)]
pub use nybbles::{self, Nibbles};

Expand Down
1 change: 1 addition & 0 deletions src/nodes/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl fmt::Debug for LeafNode<'_> {
mod tests {
use super::*;
use alloy_primitives::hex;
use std::vec;

// From manual regression test
#[test]
Expand Down

0 comments on commit 459915f

Please sign in to comment.