ChainWriteTicketOperations

Trait ChainWriteTicketOperations 

Source
pub trait ChainWriteTicketOperations {
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn redeem_ticket<'a, 'async_trait>(
        &'a self,
        ticket: RedeemableTicket,
    ) -> Pin<Box<dyn Future<Output = Result<BoxFuture<'a, Result<(VerifiedTicket, ChainReceipt), TicketRedeemError<Self::Error>>>, TicketRedeemError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;

    // Provided method
    fn redeem_tickets_via_selectors<'life0, 'life1, 'async_trait, Db, S, I>(
        &'life0 self,
        db: &'life1 Db,
        selectors: I,
    ) -> Pin<Box<dyn Future<Output = Result<BatchRedemptionResult<Self::Error>, Db::Error>> + Send + 'async_trait>>
       where Db: HoprDbTicketOperations + Sync + 'async_trait,
             I: IntoIterator<Item = S> + Send + 'async_trait,
             S: Into<TicketSelector> + 'async_trait,
             Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

On-chain write operations with tickets.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn redeem_ticket<'a, 'async_trait>( &'a self, ticket: RedeemableTicket, ) -> Pin<Box<dyn Future<Output = Result<BoxFuture<'a, Result<(VerifiedTicket, ChainReceipt), TicketRedeemError<Self::Error>>>, TicketRedeemError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Redeems a single ticket on-chain.

The input ticket is always returned as VerifiedTicket, either on success or failure.

Provided Methods§

Source

fn redeem_tickets_via_selectors<'life0, 'life1, 'async_trait, Db, S, I>( &'life0 self, db: &'life1 Db, selectors: I, ) -> Pin<Box<dyn Future<Output = Result<BatchRedemptionResult<Self::Error>, Db::Error>> + Send + 'async_trait>>
where Db: HoprDbTicketOperations + Sync + 'async_trait, I: IntoIterator<Item = S> + Send + 'async_trait, S: Into<TicketSelector> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches a batch of tickets via selector to HoprDbTicketOperations and performs batched ticket redemption.

The function takes care of properly marking the tickets in the DB as being redeemed and also properly unmarking or removing them on redemption success or failure.

The method waits until all matched tickets are either redeemed or fail to redeem, reporting the results in the BatchRedemptionResult object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'b, T: 'b + ChainWriteTicketOperations + ?Sized + Sync> ChainWriteTicketOperations for &'b T

Source§

type Error = <T as ChainWriteTicketOperations>::Error

Source§

fn redeem_ticket<'a, 'async_trait>( &'a self, ticket: RedeemableTicket, ) -> Pin<Box<dyn Future<Output = Result<BoxFuture<'a, Result<(VerifiedTicket, ChainReceipt), TicketRedeemError<Self::Error>>>, TicketRedeemError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Source§

fn redeem_tickets_via_selectors<'life0, 'life1, 'async_trait, Db, S, I>( &'life0 self, db: &'life1 Db, selectors: I, ) -> Pin<Box<dyn Future<Output = Result<BatchRedemptionResult<Self::Error>, Db::Error>> + Send + 'async_trait>>
where Db: HoprDbTicketOperations + Sync + 'async_trait, I: IntoIterator<Item = S> + Send + 'async_trait, S: Into<TicketSelector> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: ChainWriteTicketOperations + ?Sized + Sync> ChainWriteTicketOperations for Box<T>

Source§

type Error = <T as ChainWriteTicketOperations>::Error

Source§

fn redeem_ticket<'a, 'async_trait>( &'a self, ticket: RedeemableTicket, ) -> Pin<Box<dyn Future<Output = Result<BoxFuture<'a, Result<(VerifiedTicket, ChainReceipt), TicketRedeemError<Self::Error>>>, TicketRedeemError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Source§

fn redeem_tickets_via_selectors<'life0, 'life1, 'async_trait, Db, S, I>( &'life0 self, db: &'life1 Db, selectors: I, ) -> Pin<Box<dyn Future<Output = Result<BatchRedemptionResult<Self::Error>, Db::Error>> + Send + 'async_trait>>
where Db: HoprDbTicketOperations + Sync + 'async_trait, I: IntoIterator<Item = S> + Send + 'async_trait, S: Into<TicketSelector> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<T: ChainWriteTicketOperations + ?Sized + Sync> ChainWriteTicketOperations for Arc<T>

Source§

type Error = <T as ChainWriteTicketOperations>::Error

Source§

fn redeem_ticket<'a, 'async_trait>( &'a self, ticket: RedeemableTicket, ) -> Pin<Box<dyn Future<Output = Result<BoxFuture<'a, Result<(VerifiedTicket, ChainReceipt), TicketRedeemError<Self::Error>>>, TicketRedeemError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Source§

fn redeem_tickets_via_selectors<'life0, 'life1, 'async_trait, Db, S, I>( &'life0 self, db: &'life1 Db, selectors: I, ) -> Pin<Box<dyn Future<Output = Result<BatchRedemptionResult<Self::Error>, Db::Error>> + Send + 'async_trait>>
where Db: HoprDbTicketOperations + Sync + 'async_trait, I: IntoIterator<Item = S> + Send + 'async_trait, S: Into<TicketSelector> + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§