pub trait HoprDbTicketOperations {
Show 18 methods
// Required methods
fn get_all_tickets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_tickets<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, AcknowledgedTicket>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics>> + 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<()>> + 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, Balance)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>>> + 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>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn prepare_aggregation_in_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
channel: &'life1 Hash,
prerequisites: AggregationPrerequisites,
) -> Pin<Box<dyn Future<Output = Result<Option<(OffchainPublicKey, Vec<TransferableWinningTicket>, Hash)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn rollback_aggregation_in_channel<'life0, 'async_trait>(
&'life0 self,
channel: Hash,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn process_received_aggregated_ticket<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregated_ticket: Ticket,
chain_keypair: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AcknowledgedTicket>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn aggregate_tickets<'life0, 'life1, 'async_trait>(
&'life0 self,
destination: OffchainPublicKey,
acked_tickets: Vec<TransferableWinningTicket>,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<VerifiedTicket>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Required Methods§
Sourcefn get_all_tickets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_tickets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve acknowledged winning tickets, according to the given selector
.
The optional transaction tx
must be in the database.
Sourcefn get_tickets<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tickets<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
) -> Pin<Box<dyn Future<Output = Result<Vec<AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve acknowledged winning tickets, according to the given selector
.
The optional transaction tx
must be in the database.
Sourcefn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn mark_tickets_as<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
mark_as: TicketMarker,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
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, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_unsaved_ticket_rejected<'life0, 'life1, 'async_trait>(
&'life0 self,
ticket: &'life1 Ticket,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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<BoxStream<'a, AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn update_ticket_states_and_fetch<'a, 'async_trait>(
&'a self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, AcknowledgedTicket>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: '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>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_ticket_states<'life0, 'async_trait>(
&'life0 self,
selector: TicketSelector,
new_state: AcknowledgedTicketStatus,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
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<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_ticket_statistics<'life0, 'async_trait>(
&'life0 self,
channel_id: Option<Hash>,
) -> Pin<Box<dyn Future<Output = Result<ChannelTicketStatistics>> + 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<()>> + 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<()>> + 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, Balance)>> + 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, Balance)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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: Hash,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compare_and_set_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
index: u64,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn increment_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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: Hash,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_outgoing_ticket_index<'life0, 'async_trait>(
&'life0 self,
channel_id: Hash,
) -> Pin<Box<dyn Future<Output = Result<Arc<AtomicU64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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>> + 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>> + 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.
Sourcefn prepare_aggregation_in_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
channel: &'life1 Hash,
prerequisites: AggregationPrerequisites,
) -> Pin<Box<dyn Future<Output = Result<Option<(OffchainPublicKey, Vec<TransferableWinningTicket>, Hash)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn prepare_aggregation_in_channel<'life0, 'life1, 'async_trait>(
&'life0 self,
channel: &'life1 Hash,
prerequisites: AggregationPrerequisites,
) -> Pin<Box<dyn Future<Output = Result<Option<(OffchainPublicKey, Vec<TransferableWinningTicket>, Hash)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepare a viable collection of tickets to be aggregated.
Some preconditions for tickets apply. This callback will collect the aggregatable tickets and marks them as being aggregated.
Sourcefn rollback_aggregation_in_channel<'life0, 'async_trait>(
&'life0 self,
channel: Hash,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rollback_aggregation_in_channel<'life0, 'async_trait>(
&'life0 self,
channel: Hash,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform a ticket aggregation rollback in the channel.
If a ticket aggregation fails, this callback can be invoked to make sure that resources are properly restored and cleaned up in the database, allowing further aggregations.
Sourcefn process_received_aggregated_ticket<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregated_ticket: Ticket,
chain_keypair: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AcknowledgedTicket>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn process_received_aggregated_ticket<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregated_ticket: Ticket,
chain_keypair: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AcknowledgedTicket>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Replace the aggregated tickets locally with an aggregated ticket from the counterparty.
Sourcefn aggregate_tickets<'life0, 'life1, 'async_trait>(
&'life0 self,
destination: OffchainPublicKey,
acked_tickets: Vec<TransferableWinningTicket>,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<VerifiedTicket>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn aggregate_tickets<'life0, 'life1, 'async_trait>(
&'life0 self,
destination: OffchainPublicKey,
acked_tickets: Vec<TransferableWinningTicket>,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<VerifiedTicket>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Performs ticket aggregation as an issuing party of the given tickets.