pub struct NotesFrontier { /* private fields */ }Expand description
Constant-space append frontier.
Unlike ShardedNotesTree, this type retains no leaves, cap, reverse index,
or owned-note witnesses. frontier[level] is the completed subtree covering
the rightmost set bit of leaf_count; the optional slot at depth holds the
root only when the tree is completely full. A depth-30 snapshot is at most
1,015 bytes and is therefore cheap to persist once per hot block for reorg
rollback.
Implementations§
Source§impl NotesFrontier
impl NotesFrontier
pub fn new(depth: usize, shard_height: usize) -> Result<Self, TreeError>
Sourcepub fn production() -> Self
pub fn production() -> Self
An empty frontier with the production notes-tree geometry
(NOTES_TREE_DEPTH / NOTES_SHARD_HEIGHT).
Infallible: the protocol geometry is a compile-time constant that
NotesFrontier::new accepts, which production_geometry_is_valid
asserts.
pub fn depth(&self) -> usize
pub fn shard_height(&self) -> usize
pub fn shard_size(&self) -> usize
pub fn leaf_count(&self) -> usize
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Number of completed shards: leaf_count >> shard_height.
A partially filled trailing shard is not counted, so this is exactly the
number of shard roots emitted by NotesFrontier::append so far.
Sourcepub fn append(&mut self, leaf: Fr) -> Result<FrontierAppend, TreeError>
pub fn append(&mut self, leaf: Fr) -> Result<FrontierAppend, TreeError>
Append one leaf in O(depth), returning an emitted shard root exactly when
this leaf completes a 2^shard_height subtree.
Sourcepub fn append_many(
&mut self,
leaves: &[Fr],
) -> Result<Vec<CompletedShard>, TreeError>
pub fn append_many( &mut self, leaves: &[Fr], ) -> Result<Vec<CompletedShard>, TreeError>
Append a packed logical batch atomically with respect to capacity checks.
Only completed shard descriptors are returned; leaf indices remain dense
from the pre-append leaf_count.
Sourcepub fn append_be_32(
&mut self,
leaf: &[u8; 32],
) -> Result<FrontierAppend, TreeError>
pub fn append_be_32( &mut self, leaf: &[u8; 32], ) -> Result<FrontierAppend, TreeError>
NotesFrontier::append over a canonical big-endian 32-byte leaf.
Every consumer reaching this type across a byte boundary - the wasm/TS
boundary otherwise repeats the same fr_from_be_32_checked marshalling.
Rejects non-canonical encodings rather than reducing them into the field.
Sourcepub fn root_be_32(&self) -> [u8; 32]
pub fn root_be_32(&self) -> [u8; 32]
NotesFrontier::root as canonical big-endian 32 bytes.
Sourcepub fn encode_snapshot(&self) -> Vec<u8> ⓘ
pub fn encode_snapshot(&self) -> Vec<u8> ⓘ
Canonical versioned snapshot suitable for a per-block database checkpoint.
pub fn from_snapshot_bytes(bytes: &[u8]) -> Result<Self, TreeError>
Trait Implementations§
Source§impl Clone for NotesFrontier
impl Clone for NotesFrontier
Source§fn clone(&self) -> NotesFrontier
fn clone(&self) -> NotesFrontier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NotesFrontier
impl Debug for NotesFrontier
impl Eq for NotesFrontier
Source§impl PartialEq for NotesFrontier
impl PartialEq for NotesFrontier
impl StructuralPartialEq for NotesFrontier
Auto Trait Implementations§
impl Freeze for NotesFrontier
impl RefUnwindSafe for NotesFrontier
impl Send for NotesFrontier
impl Sync for NotesFrontier
impl Unpin for NotesFrontier
impl UnsafeUnpin for NotesFrontier
impl UnwindSafe for NotesFrontier
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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