Skip to main content

SurbStore

Trait SurbStore 

Source
pub trait SurbStore {
    // Required methods
    fn find_surb(&self, matcher: SurbMatcher) -> Option<FoundSurb>;
    fn insert_surbs(
        &self,
        pseudonym: SimplePseudonym,
        surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>,
    ) -> SurbInsertOutcome;
    fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener);
    fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>;

    // Provided methods
    fn invalidate_relayer(&self, _relayer: &KeyIdent) { ... }
    fn revalidate_relayer(&self, _relayer: &KeyIdent) { ... }
}
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(&self, matcher: SurbMatcher) -> Option<FoundSurb>

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( &self, pseudonym: SimplePseudonym, surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>, ) -> SurbInsertOutcome

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, along with how many had to be dropped to make room. The eviction count must not be discarded lightly: it is the only evidence that the sender is over-producing.

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.

Provided Methods§

Source

fn invalidate_relayer(&self, _relayer: &KeyIdent)

Marks the edge from this node to relayer as unusable, so stored SURBs whose return path starts there are no longer handed out.

Used by the replying side once the payment channel towards relayer is closing or closed: replying over it would only burn the SURB. SURBs with a direct return path are unaffected — their first relayer is the final recipient and needs no channel.

Defaults to a no-op, for stores that do not track edge validity.

Source

fn revalidate_relayer(&self, _relayer: &KeyIdent)

Reverts SurbStore::invalidate_relayer once the channel towards relayer re-opens.

Defaults to a no-op, for stores that do not track edge validity.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

fn find_surb(&self, matcher: SurbMatcher) -> Option<FoundSurb>

Source§

fn insert_surbs( &self, pseudonym: SimplePseudonym, surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>, ) -> SurbInsertOutcome

Source§

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

Source§

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

Source§

fn invalidate_relayer(&self, _relayer: &KeyIdent)

Source§

fn revalidate_relayer(&self, _relayer: &KeyIdent)

Source§

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

Source§

fn find_surb(&self, matcher: SurbMatcher) -> Option<FoundSurb>

Source§

fn insert_surbs( &self, pseudonym: SimplePseudonym, surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>, ) -> SurbInsertOutcome

Source§

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

Source§

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

Source§

fn invalidate_relayer(&self, _relayer: &KeyIdent)

Source§

fn revalidate_relayer(&self, _relayer: &KeyIdent)

Source§

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

Source§

fn find_surb(&self, matcher: SurbMatcher) -> Option<FoundSurb>

Source§

fn insert_surbs( &self, pseudonym: SimplePseudonym, surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>, ) -> SurbInsertOutcome

Source§

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

Source§

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

Source§

fn invalidate_relayer(&self, _relayer: &KeyIdent)

Source§

fn revalidate_relayer(&self, _relayer: &KeyIdent)

Implementors§