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 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.
This operation should be reasonably fast and should not block the main processing pipeline.
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.