pub struct StoreValidator<S> { /* private fields */ }Available on crate feature
std only.Expand description
A validator that uses a BatchStore for validation.
This validator performs comprehensive validation:
- Retrieves the batch from the store
- Checks the batch is usable (enough confirmations)
- Checks the batch is not expired
- Validates the stamp index is within bounds
- Validates the bucket matches the chunk address
- Verifies the stamp signature matches the batch owner
§Example
ⓘ
use nectar_postage::{StoreValidator, BatchStore};
let store = MyBatchStore::new();
let validator = StoreValidator::new(store, 50); // 50 block confirmations
let result = validator.validate(&stamp, &address).await;Implementations§
Source§impl<S> StoreValidator<S>
impl<S> StoreValidator<S>
Sourcepub const fn new(store: S, confirmation_threshold: u64) -> Self
pub const fn new(store: S, confirmation_threshold: u64) -> Self
Creates a new store validator.
§Arguments
store- The batch store to use for lookupsconfirmation_threshold- Minimum block confirmations for a batch to be usable
Sourcepub const fn confirmation_threshold(&self) -> u64
pub const fn confirmation_threshold(&self) -> u64
Returns the confirmation threshold.
Source§impl<S: BatchStore + Sync> StoreValidator<S>
impl<S: BatchStore + Sync> StoreValidator<S>
Sourcepub async fn validate(
&self,
stamp: &Stamp,
address: &SwarmAddress,
) -> Result<(), StampError>
pub async fn validate( &self, stamp: &Stamp, address: &SwarmAddress, ) -> Result<(), StampError>
Validates a stamp asynchronously.
This performs full validation including signature verification.
§Returns
Ok(()) if the stamp is valid, or a StampError describing the failure.
Sourcepub async fn validate_structure(
&self,
stamp: &Stamp,
address: &SwarmAddress,
) -> Result<(), StampError>
pub async fn validate_structure( &self, stamp: &Stamp, address: &SwarmAddress, ) -> Result<(), StampError>
Validates the structural properties without signature verification.
This is faster than full validation when you only need to check that the stamp references a valid batch and bucket.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for StoreValidator<S>where
S: Freeze,
impl<S> RefUnwindSafe for StoreValidator<S>where
S: RefUnwindSafe,
impl<S> Send for StoreValidator<S>where
S: Send,
impl<S> Sync for StoreValidator<S>where
S: Sync,
impl<S> Unpin for StoreValidator<S>where
S: Unpin,
impl<S> UnsafeUnpin for StoreValidator<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for StoreValidator<S>where
S: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more