pub trait HoprDbTicketOperations {
type Error: Error + Send + Sync + 'static;
Show 13 methods
// Required methods
fn stream_tickets<'c, 'async_trait>(
&'c self,
selector: Option<TicketSelector>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'c>>, Self::Error>> + Send + 'async_trait>>
where 'c: 'async_trait,
Self: 'async_trait;
fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'a>>, Self::Error>> + Send + 'async_trait>>
where 'a: 'async_trait,
Self: 'async_trait;
fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<HashBase<CoreWrapper<Keccak256Core>>>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, Balance<WxHOPR>), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: '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 'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Database operations for tickets.
Required Associated Types§
Required Methods§
Sourcefn stream_tickets<'c, 'async_trait>(
&'c self,
selector: Option<TicketSelector>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'c>>, Self::Error>> + Send + 'async_trait>>where
'c: 'async_trait,
Self: 'async_trait,
fn stream_tickets<'c, 'async_trait>(
&'c self,
selector: Option<TicketSelector>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'c>>, Self::Error>> + Send + 'async_trait>>where
'c: 'async_trait,
Self: 'async_trait,
Retrieve acknowledged winning tickets, according to the given selector
.
If no selector is given, streams tickets in all channels.
Sourcefn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'a>>, Self::Error>> + Send + 'async_trait>>where
'a: 'async_trait,
Self: 'async_trait,
fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = AcknowledgedTicket> + Send + 'a>>, Self::Error>> + Send + 'async_trait>>where
'a: 'async_trait,
Self: 'async_trait,
Updates state of the tickets matching the given selector
.
Returns the updated tickets in the new state.
Sourcefn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Updates state of the tickets matching the given selector
.
Sourcefn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<HashBase<CoreWrapper<Keccak256Core>>>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<HashBase<CoreWrapper<Keccak256Core>>>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
fn reset_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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, Balance<WxHOPR>), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_tickets_value<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<(usize, Balance<WxHOPR>), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Counts the tickets matching the given selector
and their total value.
The optional transaction tx
must be in the database.
Sourcefn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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 get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: HashBase<CoreWrapper<Keccak256Core>>,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Gets the current outgoing ticket index for the given channel id.
If the entry is not yet present for the given ID, it is initialized to 0.
Sourcefn persist_outgoing_ticket_indices<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: '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.