pub struct WasmShardedNotesTree { /* private fields */ }Expand description
Rust-owned sharded notes tree. Field elements cross this bulk boundary as canonical packed 32-byte big-endian values, avoiding one JS↔wasm call and one decimal-string allocation per Poseidon node.
Implementations§
Source§impl WasmShardedNotesTree
impl WasmShardedNotesTree
pub fn new( depth: u32, shard_height: u32, ) -> Result<WasmShardedNotesTree, JsError>
Sourcepub fn restore(snapshot: &[u8]) -> Result<WasmShardedNotesTree, JsError>
pub fn restore(snapshot: &[u8]) -> Result<WasmShardedNotesTree, JsError>
Restore a versioned snapshot previously returned by Self::snapshot.
Sourcepub fn restore_parts(
depth: u32,
shard_height: u32,
packed_completed_roots: &[u8],
packed_live_leaves: &[u8],
) -> Result<WasmShardedNotesTree, JsError>
pub fn restore_parts( depth: u32, shard_height: u32, packed_completed_roots: &[u8], packed_live_leaves: &[u8], ) -> Result<WasmShardedNotesTree, JsError>
Restore public tree state from storage tables before account-scoped witnesses are marked/adopted.
Sourcepub fn append(&mut self, note_id: &[u8]) -> Result<(), JsError>
pub fn append(&mut self, note_id: &[u8]) -> Result<(), JsError>
Append one canonical 32-byte note commitment.
Sourcepub fn append_many(&mut self, packed_note_ids: &[u8]) -> Result<(), JsError>
pub fn append_many(&mut self, packed_note_ids: &[u8]) -> Result<(), JsError>
Append N concatenated 32-byte note commitments in one wasm call.
pub fn mark_owned( &mut self, note_id: &[u8], leaf_index: u32, ) -> Result<(), JsError>
pub fn unmark_owned(&mut self, note_id: &[u8]) -> Result<bool, JsError>
pub fn adopt_frozen_witness( &mut self, note_id: &[u8], leaf_index: u32, packed_siblings: &[u8], ) -> Result<(), JsError>
pub fn witness(&self, note_id: &[u8]) -> Result<WasmInclusionProof, JsError>
Sourcepub fn rewind_live_to(&mut self, leaf_count: u32) -> Result<Vec<u8>, JsError>
pub fn rewind_live_to(&mut self, leaf_count: u32) -> Result<Vec<u8>, JsError>
Rewind only within the current live shard. Restore an earlier persisted snapshot when a rollback crosses a completed-shard boundary.
pub fn root(&self) -> Vec<u8> ⓘ
pub fn depth(&self) -> u32
pub fn shard_height(&self) -> u32
pub fn shard_size(&self) -> u32
pub fn leaf_count(&self) -> u32
pub fn completed_shard_count(&self) -> u32
pub fn owned_note_count(&self) -> u32
pub fn completed_shard_roots(&self) -> Vec<u8> ⓘ
pub fn completed_shard_root(&self, shard_index: u32) -> Result<Vec<u8>, JsError>
pub fn live_leaves(&self) -> Vec<u8> ⓘ
pub fn drain_dirty_owned_notes(&mut self) -> Vec<WasmOwnedNoteWitness>
pub fn owned_notes(&self) -> Vec<WasmOwnedNoteWitness>
Trait Implementations§
Source§impl From<WasmShardedNotesTree> for JsValue
impl From<WasmShardedNotesTree> for JsValue
Source§fn from(value: WasmShardedNotesTree) -> Self
fn from(value: WasmShardedNotesTree) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmShardedNotesTree
impl FromWasmAbi for WasmShardedNotesTree
Source§impl IntoWasmAbi for WasmShardedNotesTree
impl IntoWasmAbi for WasmShardedNotesTree
Source§impl LongRefFromWasmAbi for WasmShardedNotesTree
impl LongRefFromWasmAbi for WasmShardedNotesTree
Source§type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmShardedNotesTree>
type Anchor = RcRef<WasmShardedNotesTree>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl RefFromWasmAbi for WasmShardedNotesTree
impl RefFromWasmAbi for WasmShardedNotesTree
Source§type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<WasmShardedNotesTree>
type Anchor = RcRef<WasmShardedNotesTree>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmShardedNotesTree
impl RefMutFromWasmAbi for WasmShardedNotesTree
Source§type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
type Abi = WasmPtr<WasmRefCell<WasmShardedNotesTree>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmShardedNotesTree>
type Anchor = RcRefMut<WasmShardedNotesTree>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmShardedNotesTree
impl SupportsInstanceProperty for WasmShardedNotesTree
impl SupportsStaticProperty for WasmShardedNotesTree
Source§impl VectorFromWasmAbi for WasmShardedNotesTree
impl VectorFromWasmAbi for WasmShardedNotesTree
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmShardedNotesTree]>
Source§impl VectorIntoWasmAbi for WasmShardedNotesTree
impl VectorIntoWasmAbi for WasmShardedNotesTree
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmShardedNotesTree]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmShardedNotesTree
impl WasmDescribeVector for WasmShardedNotesTree
Auto Trait Implementations§
impl Freeze for WasmShardedNotesTree
impl RefUnwindSafe for WasmShardedNotesTree
impl Send for WasmShardedNotesTree
impl Sync for WasmShardedNotesTree
impl Unpin for WasmShardedNotesTree
impl UnsafeUnpin for WasmShardedNotesTree
impl UnwindSafe for WasmShardedNotesTree
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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 moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.