TicketTracker

Trait TicketTracker 

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

    // Required methods
    fn next_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
        &'life0 self,
        channel_id: &'life1 ChannelId,
        epoch: u32,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn incoming_channel_unrealized_balance<'life0, 'life1, 'async_trait>(
        &'life0 self,
        channel_id: &'life1 ChannelId,
        epoch: u32,
    ) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn create_multihop_ticket<'life0, 'life1, 'async_trait>(
        &'life0 self,
        channel: &'life1 ChannelEntry,
        current_path_pos: u8,
        winning_prob: WinningProbability,
        ticket_price: HoprBalance,
    ) -> Pin<Box<dyn Future<Output = Result<TicketBuilder, TicketCreationError<Self::Error>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Allows tracking ticket indices of outgoing channels and unrealized balances of incoming channels.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn next_outgoing_ticket_index<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets the next ticket index for an outgoing ticket for the given channel.

Source

fn incoming_channel_unrealized_balance<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves the unrealized balance of the given channel.

This allows guarding from situations where the ticket issuer issues more tickets than there’s balance in the given channel.

Provided Methods§

Source

fn create_multihop_ticket<'life0, 'life1, 'async_trait>( &'life0 self, channel: &'life1 ChannelEntry, current_path_pos: u8, winning_prob: WinningProbability, ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<TicketBuilder, TicketCreationError<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Convenience function that allows creating multi-hop tickets.

Implementations on Foreign Types§

Source§

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

Source§

type Error = <T as TicketTracker>::Error

Source§

fn next_outgoing_ticket_index<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn incoming_channel_unrealized_balance<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn create_multihop_ticket<'life0, 'life1, 'async_trait>( &'life0 self, channel: &'life1 ChannelEntry, current_path_pos: u8, winning_prob: WinningProbability, ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<TicketBuilder, TicketCreationError<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

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

Source§

type Error = <T as TicketTracker>::Error

Source§

fn next_outgoing_ticket_index<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn incoming_channel_unrealized_balance<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn create_multihop_ticket<'life0, 'life1, 'async_trait>( &'life0 self, channel: &'life1 ChannelEntry, current_path_pos: u8, winning_prob: WinningProbability, ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<TicketBuilder, TicketCreationError<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

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

Source§

type Error = <T as TicketTracker>::Error

Source§

fn next_outgoing_ticket_index<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn incoming_channel_unrealized_balance<'life0, 'life1, 'async_trait>( &'life0 self, channel_id: &'life1 ChannelId, epoch: u32, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn create_multihop_ticket<'life0, 'life1, 'async_trait>( &'life0 self, channel: &'life1 ChannelEntry, current_path_pos: u8, winning_prob: WinningProbability, ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<TicketBuilder, TicketCreationError<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

Source§

impl<Chain, Db> TicketTracker for HoprTicketProcessor<Chain, Db>
where Chain: Send + Sync, Db: HoprDbTicketOperations + Clone + Send + Sync + 'static,