Merge remote-tracking branch 'upstream/hotfix/shardtree-v0.3.x' into merge_shardtree_hotfix
This commit is contained in:
commit
fb62fb6175
|
@ -132,6 +132,9 @@ pruning in the presence of inserted `Frontier` nodes. See the `Removed` and
|
|||
annotation data being discarded when pruning a `Parent` node having
|
||||
`Nil` nodes for both its left and right children.
|
||||
|
||||
## [0.3.2] - 2024-12-09
|
||||
- Replaces `unwrap` calls with `expect` calls & documents panics.
|
||||
|
||||
## [0.3.1] - 2024-04-03
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -169,6 +169,10 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
|||
///
|
||||
/// Returns a copy of this tree updated to include the witness nodes, any partial supertree that is
|
||||
/// produced from nodes "higher" in the witness tree
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `witness` corresponds to the empty tree.
|
||||
pub fn insert_witness_nodes<C, const DEPTH: u8>(
|
||||
&self,
|
||||
witness: IncrementalWitness<H, DEPTH>,
|
||||
|
@ -179,7 +183,11 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
|||
// construct the subtree and cap based on the frontier containing the
|
||||
// witnessed position
|
||||
let (past_subtree, past_supertree) = self.insert_frontier_nodes::<C>(
|
||||
witness.tree().to_frontier().take().unwrap(),
|
||||
witness
|
||||
.tree()
|
||||
.to_frontier()
|
||||
.take()
|
||||
.expect("IncrementalWitness must not be created from the empty tree."),
|
||||
&Retention::Marked,
|
||||
)?;
|
||||
|
||||
|
|
|
@ -405,6 +405,10 @@ impl<
|
|||
}
|
||||
|
||||
/// Adds a checkpoint at the rightmost leaf state of the tree.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `root` represents a parent node but `root_addr` is a depth-0 leaf address.
|
||||
pub fn checkpoint(&mut self, checkpoint_id: C) -> Result<bool, ShardTreeError<S::Error>> {
|
||||
/// Pre-condition: `root_addr` must be the address of `root`.
|
||||
fn go<H: Hashable + Clone + PartialEq>(
|
||||
|
|
|
@ -153,7 +153,9 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
|
|||
|| {
|
||||
// Compute the roots of the left and right children and hash them
|
||||
// together.
|
||||
let (l_addr, r_addr) = root_addr.children().unwrap();
|
||||
let (l_addr, r_addr) = root_addr
|
||||
.children()
|
||||
.expect("The root address of a parent node must have children.");
|
||||
accumulate_result_with(
|
||||
left.root_hash(l_addr, truncate_at),
|
||||
right.root_hash(r_addr, truncate_at),
|
||||
|
@ -241,6 +243,7 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
|
|||
/// returned error contains the address of the node where such a conflict occurred.
|
||||
#[tracing::instrument()]
|
||||
pub fn merge_checked(self, root_addr: Address, other: Self) -> Result<Self, Address> {
|
||||
/// Pre-condition: `root_addr` must be the address of `t0` and `t1`.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn go<H: Hashable + Clone + PartialEq>(
|
||||
addr: Address,
|
||||
|
@ -293,7 +296,9 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
|
|||
}),
|
||||
) = (lparent, rparent)
|
||||
{
|
||||
let (l_addr, r_addr) = addr.children().unwrap();
|
||||
let (l_addr, r_addr) = addr
|
||||
.children()
|
||||
.expect("The root address of a parent node must have children.");
|
||||
Ok(Tree::unite(
|
||||
addr.level() - 1,
|
||||
lann.or(rann),
|
||||
|
|
Loading…
Reference in New Issue