SurbStore

Trait SurbStore 

Source
pub trait SurbStore {
    // Required methods
    fn find_surb<'life0, 'async_trait>(
        &'life0 self,
        matcher: SurbMatcher,
    ) -> Pin<Box<dyn Future<Output = Option<FoundSurb>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn insert_surbs<'life0, 'async_trait>(
        &'life0 self,
        pseudonym: HoprPseudonym,
        surbs: Vec<(HoprSurbId, HoprSurb)>,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener);
    fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>;
}
Expand description

A trait defining the operations required to store and retrieve SURBs (Single Use Reply Blocks) and their reply openers.

The sending side stores the reply openers, whereas the SURBs are stored by the replying side of the communication.

Required Methods§

Source

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

Tries to find SURB using the given matcher.

This is used by the replying side when it is about to send a reply packet back to the sender.

Source

fn insert_surbs<'life0, 'async_trait>( &'life0 self, pseudonym: HoprPseudonym, surbs: Vec<(HoprSurbId, HoprSurb)>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores the surbs and associates them with the given pseudonym.

This is used by the replying side when it receives packets containing SURBs from the sender with the given pseudonym.

Returns the total number of SURBs available for that pseudonym, including the newly inserted ones.

Source

fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)

Stores the given opener for the given sender_id.

This is done by the sending side, when it creates a packet containing a SURB to be delivered to the replying side.

The operation should happen reasonably fast, as it is called from the packet processing code.

Source

fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>

Tries to find a ReplyOpener given the sender_id.

This is done by the sending side of the original packet when the reply to that packet is received and needs to be decrypted.

The operation should happen reasonably fast, as it is called from the packet processing code.

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

fn insert_surbs<'life0, 'async_trait>( &'life0 self, pseudonym: HoprPseudonym, surbs: Vec<(HoprSurbId, HoprSurb)>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)

Source§

fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>

Source§

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

Source§

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

Source§

fn insert_surbs<'life0, 'async_trait>( &'life0 self, pseudonym: HoprPseudonym, surbs: Vec<(HoprSurbId, HoprSurb)>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)

Source§

fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>

Source§

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

Source§

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

Source§

fn insert_surbs<'life0, 'async_trait>( &'life0 self, pseudonym: HoprPseudonym, surbs: Vec<(HoprSurbId, HoprSurb)>, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)

Source§

fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>

Implementors§