pub struct HoprUnacknowledgedTicketProcessor<Chain> {
unacknowledged_tickets: Cache<OffchainPublicKey, Cache<HalfKeyChallenge, UnacknowledgedTicket>>,
seen_ticket_indices: Cache<(Address, u32, u64), ()>,
chain_api: Chain,
chain_key: ChainKeypair,
channels_dst: Hash,
cfg: HoprUnacknowledgedTicketProcessorConfig,
}Expand description
HOPR-specific implementation of UnacknowledgedTicketProcessor.
Fields§
§unacknowledged_tickets: Cache<OffchainPublicKey, Cache<HalfKeyChallenge, UnacknowledgedTicket>>§seen_ticket_indices: Cache<(Address, u32, u64), ()>Tracks ticket indices already accepted per (issuer -> this node channel, epoch), so a counterparty cannot replay the same index in many tickets (only one of which would ever be redeemable).
Keyed by the verified issuer address rather than the channel id: the destination of the channel is always this node, so the issuer identifies the channel equally well, with a smaller key and no hashing per ticket.
An entry is never removed upon acknowledgement: a ticket whose acknowledgement is withheld, or that turns out to be losing, must not allow its index to be replayed either.
Entries expire after
unack_ticket_timeout and, once
max_tracked_ticket_indices
is reached, the least-recently-used ones are evicted (see the LRU note in
insert_unacknowledged_ticket). The tracker is in-memory only and does not survive a restart.
chain_api: Chain§chain_key: ChainKeypair§channels_dst: Hash§cfg: HoprUnacknowledgedTicketProcessorConfigImplementations§
Source§impl<Chain> HoprUnacknowledgedTicketProcessor<Chain>
impl<Chain> HoprUnacknowledgedTicketProcessor<Chain>
Sourcepub fn new(
chain_api: Chain,
chain_key: ChainKeypair,
channels_dst: Hash,
cfg: HoprUnacknowledgedTicketProcessorConfig,
) -> Self
pub fn new( chain_api: Chain, chain_key: ChainKeypair, channels_dst: Hash, cfg: HoprUnacknowledgedTicketProcessorConfig, ) -> Self
Creates a new instance of the HOPR unacknowledged ticket processor.
Trait Implementations§
Source§impl<Chain: Clone> Clone for HoprUnacknowledgedTicketProcessor<Chain>
impl<Chain: Clone> Clone for HoprUnacknowledgedTicketProcessor<Chain>
Source§fn clone(&self) -> HoprUnacknowledgedTicketProcessor<Chain>
fn clone(&self) -> HoprUnacknowledgedTicketProcessor<Chain>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Chain> UnacknowledgedTicketProcessor for HoprUnacknowledgedTicketProcessor<Chain>
impl<Chain> UnacknowledgedTicketProcessor for HoprUnacknowledgedTicketProcessor<Chain>
type Error = HoprProtocolError
Source§fn insert_unacknowledged_ticket(
&self,
next_hop: &OffchainPublicKey,
challenge: HalfKeyChallenge,
ticket: UnacknowledgedTicket,
) -> Result<(), Self::Error>
fn insert_unacknowledged_ticket( &self, next_hop: &OffchainPublicKey, challenge: HalfKeyChallenge, ticket: UnacknowledgedTicket, ) -> Result<(), Self::Error>
Source§fn is_duplicate_ticket_index_error(error: &Self::Error) -> bool
fn is_duplicate_ticket_index_error(error: &Self::Error) -> bool
true if the given Self::Error was produced by a duplicate ticket index
rejection (insert_unacknowledged_ticket refusing a
ticket whose index was already accepted on the same channel and epoch). Read moreSource§fn acknowledge_tickets(
&self,
peer: OffchainPublicKey,
acks: Vec<Acknowledgement>,
) -> Result<Vec<ResolvedAcknowledgement>, TicketAcknowledgementError<Self::Error>>
fn acknowledge_tickets( &self, peer: OffchainPublicKey, acks: Vec<Acknowledgement>, ) -> Result<Vec<ResolvedAcknowledgement>, TicketAcknowledgementError<Self::Error>>
Acknowledgements from
the upstream peer. Read moreAuto Trait Implementations§
impl<Chain> !RefUnwindSafe for HoprUnacknowledgedTicketProcessor<Chain>
impl<Chain> !UnwindSafe for HoprUnacknowledgedTicketProcessor<Chain>
impl<Chain> Freeze for HoprUnacknowledgedTicketProcessor<Chain>where
Chain: Freeze,
impl<Chain> Send for HoprUnacknowledgedTicketProcessor<Chain>where
Chain: Send,
impl<Chain> Sync for HoprUnacknowledgedTicketProcessor<Chain>where
Chain: Sync,
impl<Chain> Unpin for HoprUnacknowledgedTicketProcessor<Chain>where
Chain: Unpin,
impl<Chain> UnsafeUnpin for HoprUnacknowledgedTicketProcessor<Chain>where
Chain: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more