Trait HoprDbProtocolOperations

Source
pub trait HoprDbProtocolOperations {
    // Required methods
    fn handle_acknowledgement<'life0, 'async_trait>(
        &'life0 self,
        ack: Acknowledgement,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_network_winning_probability<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<WinningProbability>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_network_ticket_price<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_surb<'life0, 'async_trait>(
        &'life0 self,
        matcher: SurbMatcher,
    ) -> Pin<Box<dyn Future<Output = Result<(HoprSenderId, HoprSurb)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn to_send_no_ack<'life0, 'async_trait>(
        &'life0 self,
        data: Box<[u8]>,
        destination: OffchainPublicKey,
    ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn to_send<'life0, 'async_trait>(
        &'life0 self,
        data: Box<[u8]>,
        routing: ResolvedTransportRouting,
        outgoing_ticket_win_prob: WinningProbability,
        outgoing_ticket_price: HoprBalance,
    ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn from_recv<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: Box<[u8]>,
        pkt_keypair: &'life1 OffchainKeypair,
        sender: OffchainPublicKey,
        outgoing_ticket_win_prob: WinningProbability,
        outgoing_ticket_price: HoprBalance,
    ) -> Pin<Box<dyn Future<Output = Result<Option<IncomingPacket>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait defining all DB functionality needed by packet/acknowledgement processing pipeline.

Required Methods§

Source

fn handle_acknowledgement<'life0, 'async_trait>( &'life0 self, ack: Acknowledgement, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Processes the acknowledgements for the pending tickets

There are three cases:

  1. There is an unacknowledged ticket and we are awaiting a half key.
  2. We were the creator of the packet, hence we do not wait for any half key
  3. The acknowledgement is unexpected and stems from a protocol bug or an attacker
Source

fn get_network_winning_probability<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<WinningProbability>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads (presumably cached) value of the network’s minimum winning probability from the DB.

Source

fn get_network_ticket_price<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads (presumably cached) value of the network’s minimum ticket price from the DB.

Source

fn find_surb<'life0, 'async_trait>( &'life0 self, matcher: SurbMatcher, ) -> Pin<Box<dyn Future<Output = Result<(HoprSenderId, HoprSurb)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to find SURB and its ID given the [SurbMatcher].

Source

fn to_send_no_ack<'life0, 'async_trait>( &'life0 self, data: Box<[u8]>, destination: OffchainPublicKey, ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process the data into an outgoing packet that is not going to be acknowledged.

Source

fn to_send<'life0, 'async_trait>( &'life0 self, data: Box<[u8]>, routing: ResolvedTransportRouting, outgoing_ticket_win_prob: WinningProbability, outgoing_ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process the data into an outgoing packet

Source

fn from_recv<'life0, 'life1, 'async_trait>( &'life0 self, data: Box<[u8]>, pkt_keypair: &'life1 OffchainKeypair, sender: OffchainPublicKey, outgoing_ticket_win_prob: WinningProbability, outgoing_ticket_price: HoprBalance, ) -> Pin<Box<dyn Future<Output = Result<Option<IncomingPacket>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process the incoming packet into data

Implementors§