shardtree: Make `BatchInsertionResult.max_insert_position` non-optional
This commit is contained in:
parent
166872e49b
commit
c05f2fac00
|
@ -8,6 +8,9 @@ and this project adheres to Rust's notion of
|
|||
## Unreleased
|
||||
|
||||
### Changed
|
||||
- `shardtree::BatchInsertionResult.max_insert_position` now has type `Position`
|
||||
instead of `Option<Position>` (all APIs return `Option<BatchInsertionResult>`
|
||||
and use `None` at that level to represent "no leaves inserted").
|
||||
- `shardtree::LocatedTree::from_parts` now returns `Option<Self>` (returning
|
||||
`None` if the provided `Address` and `Tree` are inconsistent).
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ impl<
|
|||
|
||||
values = res.remainder;
|
||||
subtree_root_addr = subtree_root_addr.next_at_level();
|
||||
max_insert_position = res.max_insert_position;
|
||||
start = max_insert_position.unwrap() + 1;
|
||||
max_insert_position = Some(res.max_insert_position);
|
||||
start = res.max_insert_position + 1;
|
||||
all_incomplete.append(&mut res.incomplete);
|
||||
} else {
|
||||
break;
|
||||
|
@ -102,7 +102,7 @@ pub struct BatchInsertionResult<H, C: Ord, I: Iterator<Item = (H, Retention<C>)>
|
|||
/// [`Node::Nil`]: crate::tree::Node::Nil
|
||||
pub incomplete: Vec<IncompleteAt>,
|
||||
/// The maximum position at which a leaf was inserted.
|
||||
pub max_insert_position: Option<Position>,
|
||||
pub max_insert_position: Position,
|
||||
/// The positions of all leaves with [`Retention::Checkpoint`] retention that were inserted.
|
||||
pub checkpoints: BTreeMap<C, Position>,
|
||||
/// The unconsumed remainder of the iterator from which leaves were inserted, if the tree
|
||||
|
@ -243,7 +243,7 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
|||
subtree: to_insert,
|
||||
contains_marked,
|
||||
incomplete,
|
||||
max_insert_position: Some(last_position),
|
||||
max_insert_position: last_position,
|
||||
checkpoints,
|
||||
remainder: values,
|
||||
},
|
||||
|
|
|
@ -787,7 +787,7 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
|||
if r.remainder.next().is_some() {
|
||||
Err(InsertionError::TreeFull)
|
||||
} else {
|
||||
Ok((r.subtree, r.max_insert_position.unwrap(), checkpoint_id))
|
||||
Ok((r.subtree, r.max_insert_position, checkpoint_id))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue