pub struct PaymentVerifier { /* private fields */ }Expand description
Main payment verifier for ant-node.
Uses:
- LRU cache for fast lookups of previously verified
XorNamevalues - EVM payment verification for new data (always required)
- Pool-level cache for merkle batch payments (avoids repeated on-chain queries)
Implementations§
Source§impl PaymentVerifier
impl PaymentVerifier
Sourcepub fn new(config: PaymentVerifierConfig) -> Self
pub fn new(config: PaymentVerifierConfig) -> Self
Create a new payment verifier.
Sourcepub fn check_payment_required(&self, xorname: &XorName) -> PaymentStatus
pub fn check_payment_required(&self, xorname: &XorName) -> PaymentStatus
Check if payment is required for the given XorName.
This is the main entry point for payment verification:
- Check LRU cache (fast path)
- If not cached, payment is required
§Arguments
xorname- The content-addressed name of the data
§Returns
PaymentStatus::CachedAsVerified- Found in local cache (previously paid)PaymentStatus::PaymentRequired- Not cached (payment required)
Sourcepub async fn verify_payment(
&self,
xorname: &XorName,
payment_proof: Option<&[u8]>,
) -> Result<PaymentStatus>
pub async fn verify_payment( &self, xorname: &XorName, payment_proof: Option<&[u8]>, ) -> Result<PaymentStatus>
Verify that a PUT request has valid payment.
This is the complete payment verification flow:
- Check if data is in cache (previously paid)
- If not, verify the provided payment proof
§Arguments
xorname- The content-addressed name of the datapayment_proof- Optional payment proof (required if not in cache)
§Returns
Ok(PaymentStatus)- Verification succeededErr(Error::Payment)- No payment and not cached, or payment invalid
§Errors
Returns an error if payment is required but not provided, or if payment is invalid.
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get cache statistics.
Auto Trait Implementations§
impl !Freeze for PaymentVerifier
impl !RefUnwindSafe for PaymentVerifier
impl Send for PaymentVerifier
impl Sync for PaymentVerifier
impl Unpin for PaymentVerifier
impl UnsafeUnpin for PaymentVerifier
impl !UnwindSafe for PaymentVerifier
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
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