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 attach_p2p_node(&self, node: Arc<P2PNode>)
pub fn attach_p2p_node(&self, node: Arc<P2PNode>)
Attach the node’s P2PNode handle so paid-quote verification can
check issuer closeness, and merkle-payment verification can check
candidate pub_keys against the DHT’s actual closest peers to the pool
midpoint.
Production startup MUST call this once the P2PNode exists. Without
it, live-DHT payment checks fail CLOSED in release builds with a visible
error and fail open in test builds. Idempotent: calling twice replaces
the handle.
Sourcepub fn close_group_size(&self) -> usize
pub fn close_group_size(&self) -> usize
Configured close-group width used by storage admission callers.
Sourcepub fn attach_storage(&self, storage: Arc<LmdbStorage>)
pub fn attach_storage(&self, storage: Arc<LmdbStorage>)
Attach the node’s LmdbStorage handle so paid-quote price-floor
checks can query the authoritative on-disk record count.
Production startup MUST call this once the storage exists; otherwise client PUTs using paid-quote verification are rejected because the local economic floor cannot be checked. Idempotent: calling twice replaces the handle.
Sourcepub fn check_payment_required(
&self,
xorname: &XorName,
context: VerificationContext,
) -> PaymentStatus
pub fn check_payment_required( &self, xorname: &XorName, context: VerificationContext, ) -> 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
The fast path is context-aware. A ClientPut lookup is satisfied only
by a close-group store verification. A PaidListAdmission lookup is
satisfied by either a paid-list or client-PUT verification.
§Arguments
xorname- The content-addressed name of the datacontext- The verification context of the caller
§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]>,
context: VerificationContext,
) -> Result<PaymentStatus>
pub async fn verify_payment( &self, xorname: &XorName, payment_proof: Option<&[u8]>, context: VerificationContext, ) -> 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)context- Which fresh admission path is verifying the proof — seeVerificationContextfor cache-strength semantics
§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 !UnwindSafe for PaymentVerifier
impl Send for PaymentVerifier
impl Sync for PaymentVerifier
impl Unpin for PaymentVerifier
impl UnsafeUnpin 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
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>
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