UnacknowledgedTicketProcessor

Trait UnacknowledgedTicketProcessor 

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

    // Required methods
    fn insert_unacknowledged_ticket<'life0, 'life1, 'async_trait>(
        &'life0 self,
        next_hop: &'life1 OffchainPublicKey,
        challenge: HalfKeyChallenge,
        ticket: UnacknowledgedTicket,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn acknowledge_ticket<'life0, 'async_trait>(
        &'life0 self,
        peer: OffchainPublicKey,
        ack: Acknowledgement,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedAcknowledgement>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Performs necessary processing of unacknowledged tickets in the HOPR packet processing pipeline.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn insert_unacknowledged_ticket<'life0, 'life1, 'async_trait>( &'life0 self, next_hop: &'life1 OffchainPublicKey, challenge: HalfKeyChallenge, ticket: UnacknowledgedTicket, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Inserts a verified unacknowledged ticket from a delivered packet into the internal storage.

The ticket corresponds to the given challenge and awaits to be acknowledged once an Acknowledgement is received from the next_hop.

Source

fn acknowledge_ticket<'life0, 'async_trait>( &'life0 self, peer: OffchainPublicKey, ack: Acknowledgement, ) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedAcknowledgement>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Finds and acknowledges previously inserted ticket, using an Acknowledgement from the upstream peer.

This function must verify the given acknowledgement and find if it contains a solution to a challenge of a previously inserted ticket.

On success, the resolution contains a decision whether the corresponding previously stored ticket was found, and whether it is winning (and thus also redeemable) or losing.

Returns Ok(None) if no Acknowledgement from peer was expected.

Returns an error if acknowledgement was expected from peer, but a ticket with the challenge corresponding to the Acknowledgement was not found.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + UnacknowledgedTicketProcessor + ?Sized> UnacknowledgedTicketProcessor for &'a T

Source§

type Error = <T as UnacknowledgedTicketProcessor>::Error

Source§

fn insert_unacknowledged_ticket<'life0, 'life1, 'async_trait>( &'life0 self, next_hop: &'life1 OffchainPublicKey, challenge: HalfKeyChallenge, ticket: UnacknowledgedTicket, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn acknowledge_ticket<'life0, 'async_trait>( &'life0 self, peer: OffchainPublicKey, ack: Acknowledgement, ) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedAcknowledgement>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T: UnacknowledgedTicketProcessor + ?Sized> UnacknowledgedTicketProcessor for Box<T>

Source§

type Error = <T as UnacknowledgedTicketProcessor>::Error

Source§

fn insert_unacknowledged_ticket<'life0, 'life1, 'async_trait>( &'life0 self, next_hop: &'life1 OffchainPublicKey, challenge: HalfKeyChallenge, ticket: UnacknowledgedTicket, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn acknowledge_ticket<'life0, 'async_trait>( &'life0 self, peer: OffchainPublicKey, ack: Acknowledgement, ) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedAcknowledgement>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T: UnacknowledgedTicketProcessor + ?Sized> UnacknowledgedTicketProcessor for Arc<T>

Source§

type Error = <T as UnacknowledgedTicketProcessor>::Error

Source§

fn insert_unacknowledged_ticket<'life0, 'life1, 'async_trait>( &'life0 self, next_hop: &'life1 OffchainPublicKey, challenge: HalfKeyChallenge, ticket: UnacknowledgedTicket, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn acknowledge_ticket<'life0, 'async_trait>( &'life0 self, peer: OffchainPublicKey, ack: Acknowledgement, ) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedAcknowledgement>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§