hopr_db_api::protocol

Trait HoprDbProtocolOperations

Source
pub trait HoprDbProtocolOperations {
    // Required methods
    fn handle_acknowledgement<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ack: Acknowledgement,
        me: &'life1 ChainKeypair,
    ) -> Pin<Box<dyn Future<Output = Result<AckResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn to_send<'life0, 'async_trait>(
        &'life0 self,
        data: Box<[u8]>,
        me: ChainKeypair,
        path: Vec<OffchainPublicKey>,
        outgoing_ticket_win_prob: f64,
    ) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData, DbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn from_recv<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: Box<[u8]>,
        me: ChainKeypair,
        pkt_keypair: &'life1 OffchainKeypair,
        sender: OffchainPublicKey,
        outgoing_ticket_win_prob: f64,
    ) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData>> + 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, 'life1, 'async_trait>( &'life0 self, ack: Acknowledgement, me: &'life1 ChainKeypair, ) -> Pin<Box<dyn Future<Output = Result<AckResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: '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 to_send<'life0, 'async_trait>( &'life0 self, data: Box<[u8]>, me: ChainKeypair, path: Vec<OffchainPublicKey>, outgoing_ticket_win_prob: f64, ) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData, DbError>> + 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]>, me: ChainKeypair, pkt_keypair: &'life1 OffchainKeypair, sender: OffchainPublicKey, outgoing_ticket_win_prob: f64, ) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process the incoming packet into data

Implementors§