pub trait UnacknowledgedTicketProcessor {
type Error: Error + Send + Sync + 'static;
// Required methods
fn insert_unacknowledged_ticket(
&self,
next_hop: &OffchainPublicKey,
challenge: HalfKeyChallenge,
ticket: UnacknowledgedTicket,
) -> Result<(), Self::Error>;
fn is_duplicate_ticket_index_error(error: &Self::Error) -> bool;
fn acknowledge_tickets(
&self,
peer: OffchainPublicKey,
acks: Vec<Acknowledgement>,
) -> Result<Vec<ResolvedAcknowledgement>, TicketAcknowledgementError<Self::Error>>;
}Expand description
Performs necessary processing of unacknowledged tickets in the HOPR packet processing pipeline.
Required Associated Types§
Required Methods§
Sourcefn 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>
Inserts a verified unacknowledged ticket from a delivered packet into the internal storage.
The ticket corresponds to the given challenge
and awaits to be acknowledged
once an [Acknowledgement] is received from the next_hop.
Duplicates are detected per (issuer -> this node channel, epoch, index): Err is returned if
a ticket with the same index was already accepted on that channel and epoch (an attacker must
not be able to have many tickets accepted on the same index, since only one of them would
ever be redeemable). Implementations may bound how long an accepted index is remembered (the
HOPR implementation forgets it after unack_ticket_timeout or once its capacity is exceeded),
after which the same index is accepted again.
This operation should be reasonably fast and should not block the main processing pipeline.
Sourcefn is_duplicate_ticket_index_error(error: &Self::Error) -> bool
fn is_duplicate_ticket_index_error(error: &Self::Error) -> bool
Returns 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).
Used by the processing pipeline to give such rejections their own rejection metric label. This method has no default so every processor must state explicitly whether its error type can carry this rejection.
Sourcefn 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>>
Finds and acknowledges previously inserted tickets, using incoming Acknowledgements from
the upstream peer.
Function should first check if any acknowledgements are expected from the given peer.
Furthermore, the function must verify each given acknowledgement and find if it evaluates to any solutions to challenges of previously inserted tickets.
On success, the resolutions contain decisions whether the previously stored ticket with a matching challenge was found, and whether it is winning (and thus also redeemable) or losing. Challenges for which tickets were not found are skipped.
Must return TicketAcknowledgementError::UnexpectedAcknowledgement if no Acknowledgements from the given
peer was expected.
This operation is expected to be somewhat long-running and significantly blocking.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".