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§
Sourcefn find_surb(&self, matcher: SurbMatcher) -> Option<FoundSurb>
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.
Sourcefn insert_surbs(
&self,
pseudonym: SimplePseudonym,
surbs: Vec<([u8; 8], SURB<Ed25519Suite, HoprSphinxHeaderSpec>)>,
) -> SurbInsertOutcome
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.
Sourcefn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)
fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)
Sourcefn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>
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§
Sourcefn invalidate_relayer(&self, _relayer: &KeyIdent)
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.
Sourcefn revalidate_relayer(&self, _relayer: &KeyIdent)
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".