HoprDbProtocolOperations

Trait HoprDbProtocolOperations 

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

    // Required methods
    fn handle_acknowledgement<'life0, 'life1, 'async_trait, R>(
        &'life0 self,
        ack: VerifiedAcknowledgement,
        chain_resolver: &'life1 R,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             R: ChainReadChannelOperations + ChainValues + Send + Sync + 'async_trait,
             Self: 'async_trait;
    fn find_surb<'life0, 'async_trait>(
        &'life0 self,
        matcher: SurbMatcher,
    ) -> Pin<Box<dyn Future<Output = Result<FoundSurb, Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_surb_config(&self) -> SurbCacheConfig;
    fn to_send_no_ack<'life0, 'life1, 'async_trait, R>(
        &'life0 self,
        data: Box<[u8]>,
        destination: OffchainPublicKey,
        resolver: &'life1 R,
    ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             R: ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
             Self: 'async_trait;
    fn to_send<'life0, 'life1, 'async_trait, R>(
        &'life0 self,
        data: Box<[u8]>,
        routing: ResolvedTransportRouting,
        outgoing_ticket_win_prob: Option<WinningProbability>,
        outgoing_ticket_price: Option<Balance<WxHOPR>>,
        signals: FlagSet<PacketSignal>,
        resolver: &'life1 R,
    ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
             Self: 'async_trait;
    fn from_recv<'life0, 'life1, 'life2, 'async_trait, R>(
        &'life0 self,
        data: Box<[u8]>,
        pkt_keypair: &'life1 OffchainKeypair,
        sender: OffchainPublicKey,
        outgoing_ticket_win_prob: Option<WinningProbability>,
        outgoing_ticket_price: Option<Balance<WxHOPR>>,
        resolver: &'life2 R,
    ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait,
             Self: 'async_trait;
}
Expand description

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

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn handle_acknowledgement<'life0, 'life1, 'async_trait, R>( &'life0 self, ack: VerifiedAcknowledgement, chain_resolver: &'life1 R, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, R: ChainReadChannelOperations + ChainValues + Send + Sync + 'async_trait, Self: '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 find_surb<'life0, 'async_trait>( &'life0 self, matcher: SurbMatcher, ) -> Pin<Box<dyn Future<Output = Result<FoundSurb, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Attempts to find SURB and its ID given the SurbMatcher.

Source

fn get_surb_config(&self) -> SurbCacheConfig

Returns the SURB cache configuration.

Source

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

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

Source

fn to_send<'life0, 'life1, 'async_trait, R>( &'life0 self, data: Box<[u8]>, routing: ResolvedTransportRouting, outgoing_ticket_win_prob: Option<WinningProbability>, outgoing_ticket_price: Option<Balance<WxHOPR>>, signals: FlagSet<PacketSignal>, resolver: &'life1 R, ) -> Pin<Box<dyn Future<Output = Result<OutgoingPacket, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait, Self: 'async_trait,

Process the data into an outgoing packet

Source

fn from_recv<'life0, 'life1, 'life2, 'async_trait, R>( &'life0 self, data: Box<[u8]>, pkt_keypair: &'life1 OffchainKeypair, sender: OffchainPublicKey, outgoing_ticket_win_prob: Option<WinningProbability>, outgoing_ticket_price: Option<Balance<WxHOPR>>, resolver: &'life2 R, ) -> Pin<Box<dyn Future<Output = Result<IncomingPacket, IncomingPacketError<Self::Error>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, R: ChainReadChannelOperations + ChainKeyOperations + ChainValues + Send + Sync + 'async_trait, Self: 'async_trait,

Process the incoming packet into data

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.

Implementors§