pub struct Stamper { /* private fields */ }Expand description
Client-side stamper that tracks per-bucket utilisation and signs envelopes for individual chunks.
Construct with Stamper::from_blank for a fresh batch or with
Stamper::from_state to resume from previously persisted bucket
counters.
Implementations§
Source§impl Stamper
impl Stamper
Sourcepub fn from_blank(
signer: PrivateKey,
batch_id: BatchId,
depth: u8,
) -> Result<Self, Error>
pub fn from_blank( signer: PrivateKey, batch_id: BatchId, depth: u8, ) -> Result<Self, Error>
New stamper with empty buckets.
Sourcepub fn from_state(
signer: PrivateKey,
batch_id: BatchId,
buckets: Vec<u32>,
depth: u8,
) -> Result<Self, Error>
pub fn from_state( signer: PrivateKey, batch_id: BatchId, buckets: Vec<u32>, depth: u8, ) -> Result<Self, Error>
Resume a stamper from previously persisted bucket counters.
buckets.len() must equal NUM_BUCKETS.
Sourcepub fn stamp(&mut self, chunk_addr: &[u8]) -> Result<Envelope, Error>
pub fn stamp(&mut self, chunk_addr: &[u8]) -> Result<Envelope, Error>
Stamp a chunk address. Increments the per-bucket counter and
returns a freshly signed Envelope. Errors with
Error::Argument if the bucket is full or the address length
is wrong.
Sourcepub fn state(&self) -> &[u32]
pub fn state(&self) -> &[u32]
Snapshot of the current bucket counters. Useful for persisting
and resuming via Stamper::from_state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stamper
impl RefUnwindSafe for Stamper
impl Send for Stamper
impl Sync for Stamper
impl Unpin for Stamper
impl UnsafeUnpin for Stamper
impl UnwindSafe for Stamper
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