pub struct ExclusionLeafData {
    /// The leaf key.
    leaf_key: MerkleTreeKey,
    /// Hash of the value of the leaf.
    leaf_value: b256,
}
Expand description

An Exclusion Proof Leaf data for a Sparse Merkle Tree.

Fields

leaf_key: MerkleTreeKey

The leaf key.

leaf_value: b256

Hash of the value of the leaf.

Implementations

pub fn new(leaf_key: MerkleTreeKey, leaf_value: b256) -> Self

Instantiates a new ExclusionLeafData from a MerkleTreeKey and b256.

Arguments

  • leaf_key: [MerkleTreeKey] - The key associated with the particular leaf in the Sparse Merkle Tree.
  • leaf_value: [b256] - The hashed value of a particular leaf in the Sparse Merkle Tree.

Returns

[ExclusionLeafData] - A newly created ExclusionLeafData.

Examples

use sway_libs::merkle::sparse::ExclusionLeafData;

fn foo() {
    let leaf_key = MerkleTreeKey::zero()
    let leaf_value = b256::zero()
    let new_leaf = ExclusionLeafData::new(leaf_key, leaf_value);
}

pub fn leaf_key(self) -> MerkleTreeKey

Returns the underlying MerkleTreeKey of the exclusion leaf.

Returns

  • [MerkleTreeKey] - The underlying MerkleTreeKey for this exclusion leaf.

Examples

use sway_libs::merkle::sparse::ExclusionLeafData;

fn foo() {
    let leaf_key = MerkleTreeKey::zero()
    let leaf_value = b256::zero()
    let new_leaf = ExclusionLeafData::new(leaf_key, leaf_value);
    let result_key = new_leaf.leaf_key();
    assert(result_key == leaf_key);
}

pub fn leaf_value(self) -> b256

Returns the underlying b256 of the exclusion leaf data.

Returns

  • [b256] - The underlying b256 data for this exclusion leaf.

Examples

use sway_libs::merkle::sparse::ExclusionLeafData;

fn foo() {
    let leaf_key = MerkleTreeKey::zero()
    let leaf_value = b256::zero()
    let new_leaf = ExclusionLeafData::new(leaf_key, leaf_value);
    let result_hash = new_leaf.leaf_key();
    assert(result_hash == leaf_value);
}

Trait Implementations

pub fn abi_encode(self, buffer: Buffer) -> Buffer

pub fn abi_decode(refmut buffer: BufferReader) -> Self

pub fn eq(self, other: Self) -> bool

pub fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

Additional Information

This function is inherited when eq() is implemented.

Arguments

  • other: [Self] - The value of the same type.

Returns

  • [bool] - true if the two values are not equal, otherwise false.

Examples

struct MyStruct {
    val: u64,
}

impl PartialEq for MyStruct {
    fn eq(self, other: Self) -> bool {
         self.val == other.val
    }
}

fn foo() {
    let struct1 = MyStruct { val: 10 };
    let struct2 = MyStruct { val: 2 };
    let result = struct1 != struct2;
    assert(result);
}