pub trait HoprDbTicketOperations {
type Error: Error + Send + Sync + 'static;
Show 13 methods
// Required methods
fn stream_tickets<'c, 'async_trait, S, I>(
&'c self,
selectors: I,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'c, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>
where S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'c: 'async_trait;
fn insert_ticket<'life0, 'async_trait>(
&'life0 self,
ticket: RedeemableTicket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn mark_tickets_as<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where S: 'async_trait + Into<TicketSelector> + Send,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait;
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 Address,
ticket: &'life2 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn update_ticket_states_and_fetch<'a, 'async_trait, S, I>(
&'a self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>
where S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'a: 'async_trait;
fn update_ticket_states<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait;
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<ChannelId>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, HoprBalance), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn compare_and_set_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn reset_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn increment_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Database operations for tickets.
The redeemable winning tickets enter the DB via [HoprDb::insert_ticket] and can only leave the DB
when marked via HoprDbTicketOperations::mark_tickets_as
The overall value of tickets in the DB and of those that left the DB is tracked
via the ChannelTicketStatistics by calling the HoprDbTicketOperations::get_ticket_statistics.
The statistics can also track tickets that were rejected before entering the DB,
which can be done via HoprDbTicketOperations::mark_unsaved_ticket_rejected.
NOTE: tickets that are not winning are NOT considered as rejected. Non-winning tickets are therefore not tracked in any statistics, also for performance reasons.
Required Associated Types§
Required Methods§
Sourcefn stream_tickets<'c, 'async_trait, S, I>(
&'c self,
selectors: I,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'c, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'c: 'async_trait,
fn stream_tickets<'c, 'async_trait, S, I>(
&'c self,
selectors: I,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'c, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'c: 'async_trait,
Retrieve acknowledged winning tickets, according to the given selectors.
If no selector is given, streams tickets in all channels.
Sourcefn insert_ticket<'life0, 'async_trait>(
&'life0 self,
ticket: RedeemableTicket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert_ticket<'life0, 'async_trait>(
&'life0 self,
ticket: RedeemableTicket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Inserts a new winning ticket into the DB.
Returns an error if the ticket already exists.
Sourcefn mark_tickets_as<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector> + Send,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait,
fn mark_tickets_as<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector> + Send,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait,
Marks tickets as the given TicketMarker, removing them from the DB and updating the
ticket statistics for each ticket’s channel.
Returns the number of marked tickets.
Sourcefn mark_unsaved_ticket_rejected<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 Address,
ticket: &'life2 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 Address,
ticket: &'life2 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Updates the ticket statistics according to the fact that the given ticket has been rejected by the packet processing pipeline.
This ticket is not yet stored in the ticket DB; therefore, only the statistics in the corresponding channel are updated.
Sourcefn update_ticket_states_and_fetch<'a, 'async_trait, S, I>(
&'a self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'a: 'async_trait,
fn update_ticket_states_and_fetch<'a, 'async_trait, S, I>(
&'a self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, RedeemableTicket>, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'a: 'async_trait,
Updates the state of the tickets matching the given selectors.
Returns the updated tickets in the new state.
Sourcefn update_ticket_states<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait,
fn update_ticket_states<'life0, 'async_trait, S, I>(
&'life0 self,
selectors: I,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
S: 'async_trait + Into<TicketSelector>,
I: 'async_trait + IntoIterator<Item = S> + Send,
Self: 'async_trait,
'life0: 'async_trait,
Updates state of the tickets matching the given selector.
Sourcefn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<ChannelId>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<ChannelId>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the ticket statistics for the given channel.
If no channel is given, it retrieves aggregate ticket statistics for all channels.
Sourcefn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resets the ticket statistics about neglected, rejected, and redeemed tickets.
Sourcefn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, HoprBalance), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, HoprBalance), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Counts the total value of tickets matching the given selector on a single channel.
Sourcefn compare_and_set_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn compare_and_set_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sets the stored outgoing ticket index to index, only if the currently stored value
is less than index. This ensures the stored value can only be growing.
Returns the old value.
If the entry is not yet present for the given ID, it is initialized to 0.
Sourcefn reset_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reset_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resets the outgoing ticket index to 0 for the given channel id.
Returns the old value before reset.
If the entry is not yet present for the given ID, it is initialized to 0.
Sourcefn increment_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_outgoing_ticket_index<'life0, 'life1, 'async_trait>(
&'life0 self,
channel_id: &'life1 ChannelId,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Increments the outgoing ticket index in the given channel ID and returns the value before incrementing.
If the entry is not yet present for the given ID, it is initialized to 0 and incremented.
Sourcefn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Compares outgoing ticket indices in the cache with the stored values and updates the stored value where changed.
Returns the number of updated ticket indices.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.