Skip to content

Commit

Permalink
Expose Serde support for ProofNodes and DecodedProofNodes (#85)
Browse files Browse the repository at this point in the history
feat: expose serde for ProofNodes and DecodedProofNodes
  • Loading branch information
startup-dreamer authored Feb 12, 2025
1 parent 1ff76a6 commit cec9d5b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nodes/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use alloc::vec::Vec;
/// character and an additional slot for a value. We do exclude the node value since all paths have
/// a fixed size.
#[derive(PartialEq, Eq, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BranchNode {
/// The collection of RLP encoded children.
pub stack: Vec<RlpNode>,
Expand Down
1 change: 1 addition & 0 deletions src/nodes/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use alloc::vec::Vec;
/// with a single child into one node. This simplification reduces the space and computational
/// complexity when performing operations on the trie.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExtensionNode {
/// The key for this extension node.
pub key: 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 @@ -14,6 +14,7 @@ use alloc::vec::Vec;
/// 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, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LeafNode {
/// The key for this leaf node.
pub key: Nibbles,
Expand Down
1 change: 1 addition & 0 deletions src/nodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub const CHILD_INDEX_RANGE: Range<u8> = 0..16;

/// Enum representing an MPT trie node.
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum TrieNode {
/// Variant representing empty root node.
EmptyRoot,
Expand Down
1 change: 1 addition & 0 deletions src/proof/decoded_proof_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use alloc::vec::Vec;

/// A wrapper struct for trie node key to RLP encoded trie node.
#[derive(PartialEq, Eq, Clone, Default, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DecodedProofNodes(HashMap<Nibbles, TrieNode>);

impl Deref for DecodedProofNodes {
Expand Down
1 change: 1 addition & 0 deletions src/proof/proof_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloc::vec::Vec;

/// A wrapper struct for trie node key to RLP encoded trie node.
#[derive(PartialEq, Eq, Clone, Default, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ProofNodes(HashMap<Nibbles, Bytes>);

impl Deref for ProofNodes {
Expand Down

0 comments on commit cec9d5b

Please sign in to comment.