Skip to content

Commit

Permalink
chore: make TrieNode cloneable (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored Jul 28, 2024
1 parent ee03724 commit dc77954
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/nodes/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use alloc::vec::Vec;
/// A branch node in an Merkle Patricia Trie is a 17-element array consisting of 16 slots that
/// correspond to each hexadecimal character and an additional slot for a value. We do exclude
/// the node value since all paths have a fixed size.
#[derive(PartialEq, Eq, Default)]
#[derive(PartialEq, Eq, Clone, Default)]
pub struct BranchNode {
/// The collection of RLP encoded children.
pub stack: Vec<Vec<u8>>,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use alloc::vec::Vec;
/// The purpose of an extension node is to optimize the trie structure by collapsing multiple nodes
/// with a single child into one node. This simplification reduces the space and computational
/// complexity when performing operations on the trie.
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Clone)]
pub struct ExtensionNode {
/// The key for this extension node.
pub key: Nibbles,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use alloc::vec::Vec;
/// remaining portion of the key after following the path through the trie, and the value is the
/// data associated with the full key. When searching the trie for a specific key, reaching a leaf
/// node means that the search has successfully found the value associated with that key.
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Clone)]
pub struct LeafNode {
/// The key for this leaf node.
pub key: Nibbles,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use leaf::{LeafNode, LeafNodeRef};
pub const CHILD_INDEX_RANGE: Range<u8> = 0..16;

/// Enum representing an MPT trie node.
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum TrieNode {
/// Variant representing a [BranchNode].
Branch(BranchNode),
Expand Down

0 comments on commit dc77954

Please sign in to comment.