Struct bridgetree::MerkleBridge
source · pub struct MerkleBridge<H> { /* private fields */ }
Expand description
The information required to “update” witnesses from one state of a Merkle tree to another.
The witness for a particular leaf of a Merkle tree consists of the siblings of that leaf, plus
the siblings of the parents of that leaf in a path to the root of the tree. When considering a
Merkle tree where leaves are appended to the tree in a linear fashion (rather than being
inserted at arbitrary positions), we often wish to produce a witness for a leaf that was
appended to the tree at some point in the past. A MerkleBridge
from one position in the
tree to another position in the tree contains the minimal amount of information necessary to
produce a witness for the leaf at the former position, given that leaves have been subsequently
appended to reach the current position.
MerkleBridge
values have a semigroup, such that the sum (fuse
d) value of two successive
bridges, along with a NonEmptyFrontier
with its tip at the prior position of the first bridge
being fused, can be used to produce a witness for the leaf at the tip of the prior frontier.
Implementations§
source§impl<H> MerkleBridge<H>
impl<H> MerkleBridge<H>
sourcepub fn from_parts(
prior_position: Option<Position>,
tracking: BTreeSet<Address>,
ommers: BTreeMap<Address, H>,
frontier: NonEmptyFrontier<H>
) -> Self
pub fn from_parts( prior_position: Option<Position>, tracking: BTreeSet<Address>, ommers: BTreeMap<Address, H>, frontier: NonEmptyFrontier<H> ) -> Self
Construct a new Merkle bridge from its constituent parts.
sourcepub fn prior_position(&self) -> Option<Position>
pub fn prior_position(&self) -> Option<Position>
Returns the position of the final leaf in the frontier of the bridge that this bridge is the successor of, or None if this is the first bridge in a tree.
sourcepub fn tracking(&self) -> &BTreeSet<Address>
pub fn tracking(&self) -> &BTreeSet<Address>
Returns the set of internal node addresses that we’re searching for the ommers for.
sourcepub fn ommers(&self) -> &BTreeMap<Address, H>
pub fn ommers(&self) -> &BTreeMap<Address, H>
Returns the set of internal node addresses that we’re searching for the ommers for.
sourcepub fn frontier(&self) -> &NonEmptyFrontier<H>
pub fn frontier(&self) -> &NonEmptyFrontier<H>
Returns the non-empty frontier of this Merkle bridge.
sourcepub fn current_leaf(&self) -> &H
pub fn current_leaf(&self) -> &H
Returns the value of the most recently appended leaf.
sourcepub fn check_continuity(&self, next: &Self) -> Result<(), ContinuityError>
pub fn check_continuity(&self, next: &Self) -> Result<(), ContinuityError>
Checks whether this bridge is a valid successor for the specified bridge.
sourcepub fn position_range(&self) -> Range<Position>
pub fn position_range(&self) -> Range<Position>
Returns the range of positions observed by this bridge.
source§impl<'a, H: Hashable + Clone + Ord + 'a> MerkleBridge<H>
impl<'a, H: Hashable + Clone + Ord + 'a> MerkleBridge<H>
Trait Implementations§
source§impl<H: Clone> Clone for MerkleBridge<H>
impl<H: Clone> Clone for MerkleBridge<H>
source§fn clone(&self) -> MerkleBridge<H>
fn clone(&self) -> MerkleBridge<H>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<H: Debug> Debug for MerkleBridge<H>
impl<H: Debug> Debug for MerkleBridge<H>
source§impl<H: PartialEq> PartialEq<MerkleBridge<H>> for MerkleBridge<H>
impl<H: PartialEq> PartialEq<MerkleBridge<H>> for MerkleBridge<H>
source§fn eq(&self, other: &MerkleBridge<H>) -> bool
fn eq(&self, other: &MerkleBridge<H>) -> bool
self
and other
values to be equal, and is used
by ==
.