pub struct ShardedNotesTree { /* private fields */ }Expand description
Stateful depth-depth notes tree split into fixed-height shards.
Only the rightmost shard stores leaves and internal nodes. Completed shards
are represented by one root each in a mutable cap tree. Owned notes retain
their immutable within-shard path after rollover; the current cap path is
attached on demand, producing a normal depth-depth inclusion proof.
Implementations§
Source§impl ShardedNotesTree
impl ShardedNotesTree
pub fn new(depth: usize, shard_height: usize) -> Result<Self, TreeError>
pub fn from_snapshot(snapshot: ShardedTreeSnapshot) -> Result<Self, TreeError>
Sourcepub fn from_parts(
depth: usize,
shard_height: usize,
completed_roots: Vec<Fr>,
live_leaves: Vec<Fr>,
) -> Result<Self, TreeError>
pub fn from_parts( depth: usize, shard_height: usize, completed_roots: Vec<Fr>, live_leaves: Vec<Fr>, ) -> Result<Self, TreeError>
Restore the public tree state before owned witnesses are adopted. This is the bulk boundary used by storage adapters that persist shard roots, live leaves, and account-scoped witnesses in separate tables.
pub fn depth(&self) -> usize
pub fn shard_height(&self) -> usize
pub fn shard_size(&self) -> usize
pub fn leaf_count(&self) -> usize
pub fn completed_shard_count(&self) -> usize
pub fn owned_note_count(&self) -> usize
pub fn owned_notes(&self) -> Vec<OwnedNoteWitness>
pub fn completed_roots(&self) -> &[Fr] ⓘ
pub fn live_leaves(&self) -> &[Fr] ⓘ
pub fn completed_shard_root(&self, shard_index: usize) -> Result<Fr, TreeError>
Sourcepub fn append(&mut self, note_id: Fr) -> Result<(), TreeError>
pub fn append(&mut self, note_id: Fr) -> Result<(), TreeError>
Append one note commitment, updating the live shard and cap in O(depth).
Sourcepub fn append_many(&mut self, note_ids: &[Fr]) -> Result<(), TreeError>
pub fn append_many(&mut self, note_ids: &[Fr]) -> Result<(), TreeError>
Append a batch, bulk-building when that is cheaper than one insertion per leaf. Cap updates are coalesced to once per affected shard.
Sourcepub fn mark_owned(
&mut self,
note_id: Fr,
leaf_index: usize,
) -> Result<(), TreeError>
pub fn mark_owned( &mut self, note_id: Fr, leaf_index: usize, ) -> Result<(), TreeError>
Track an owned note. The note may already be in the live shard or may be marked immediately before its commitment is appended.
pub fn unmark_owned(&mut self, note_id: Fr) -> bool
Sourcepub fn adopt_frozen_witness(
&mut self,
note_id: Fr,
leaf_index: usize,
within_shard_siblings: Vec<Fr>,
) -> Result<(), TreeError>
pub fn adopt_frozen_witness( &mut self, note_id: Fr, leaf_index: usize, within_shard_siblings: Vec<Fr>, ) -> Result<(), TreeError>
Adopt a recovered local path for an owned note in a completed shard.
pub fn root(&self) -> Fr
Sourcepub fn witness(&self, note_id: Fr) -> Result<InclusionProof, TreeError>
pub fn witness(&self, note_id: Fr) -> Result<InclusionProof, TreeError>
Produce a conventional full-depth proof for a tracked owned note.
Sourcepub fn rewind_live_to(
&mut self,
leaf_count: usize,
) -> Result<Vec<Fr>, TreeError>
pub fn rewind_live_to( &mut self, leaf_count: usize, ) -> Result<Vec<Fr>, TreeError>
Rewind within the mutable live shard. Crossing a completed-shard boundary requires restoring an earlier checkpoint because completed leaves have deliberately been discarded.
pub fn drain_dirty_owned_notes(&mut self) -> Vec<OwnedNoteWitness>
pub fn snapshot(&self) -> ShardedTreeSnapshot
pub fn encode_snapshot(&self) -> Result<Vec<u8>, TreeError>
pub fn from_snapshot_bytes(bytes: &[u8]) -> Result<Self, TreeError>
Trait Implementations§
Source§impl Clone for ShardedNotesTree
impl Clone for ShardedNotesTree
Source§fn clone(&self) -> ShardedNotesTree
fn clone(&self) -> ShardedNotesTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ShardedNotesTree
impl RefUnwindSafe for ShardedNotesTree
impl Send for ShardedNotesTree
impl Sync for ShardedNotesTree
impl Unpin for ShardedNotesTree
impl UnsafeUnpin for ShardedNotesTree
impl UnwindSafe for ShardedNotesTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more