pub trait HoprDbProtocolOperations {
// Required methods
fn handle_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: Acknowledgement,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AckResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_network_winning_probability<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_network_ticket_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn to_send<'life0, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
path: Vec<OffchainPublicKey>,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData, DbError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn from_recv<'life0, 'life1, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
pkt_keypair: &'life1 OffchainKeypair,
sender: OffchainPublicKey,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
Trait defining all DB functionality needed by packet/acknowledgement processing pipeline.
Required Methods§
Sourcefn handle_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: Acknowledgement,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AckResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_acknowledgement<'life0, 'life1, 'async_trait>(
&'life0 self,
ack: Acknowledgement,
me: &'life1 ChainKeypair,
) -> Pin<Box<dyn Future<Output = Result<AckResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes the acknowledgements for the pending tickets
There are three cases:
- There is an unacknowledged ticket and we are awaiting a half key.
- We were the creator of the packet, hence we do not wait for any half key
- The acknowledgement is unexpected and stems from a protocol bug or an attacker
Sourcefn get_network_winning_probability<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_network_winning_probability<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Loads (presumably cached) value of the network’s minimum winning probability from the DB.
Sourcefn get_network_ticket_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_network_ticket_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Loads (presumably cached) value of the network’s minimum ticket price from the DB.
Sourcefn to_send<'life0, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
path: Vec<OffchainPublicKey>,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn to_send<'life0, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
path: Vec<OffchainPublicKey>,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process the data into an outgoing packet
Sourcefn from_recv<'life0, 'life1, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
pkt_keypair: &'life1 OffchainKeypair,
sender: OffchainPublicKey,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn from_recv<'life0, 'life1, 'async_trait>(
&'life0 self,
data: Box<[u8]>,
me: ChainKeypair,
pkt_keypair: &'life1 OffchainKeypair,
sender: OffchainPublicKey,
outgoing_ticket_win_prob: f64,
outgoing_ticket_price: Balance,
) -> Pin<Box<dyn Future<Output = Result<TransportPacketWithChainData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Process the incoming packet into data