pub trait HoprDbChannelOperations {
// Required methods
fn get_channel_by_id<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait;
fn begin_channel_update<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEditor>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait;
fn finish_channel_update<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
editor: ChannelEditor,
) -> Pin<Box<dyn Future<Output = Result<ChannelEntry>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn get_channel_by_parties<'a, 'life0, 'life1, 'async_trait>(
&'a self,
tx: OptTx<'a>,
src: &'life0 Address,
dst: &'life1 Address,
use_cache: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_channels_via<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
direction: ChannelDirection,
target: &'life0 Address,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait;
fn get_incoming_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn get_outgoing_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn get_all_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn stream_active_channels<'a, 'async_trait>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, Result<ChannelEntry>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
fn upsert_channel<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
channel_entry: ChannelEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
}
Expand description
Defines DB API for accessing information about HOPR payment channels.
Required Methods§
Sourcefn get_channel_by_id<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_channel_by_id<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Retrieves channel by its channel ID hash.
See generate_channel_id on how to generate a channel ID hash from source and destination Addresses.
Sourcefn begin_channel_update<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEditor>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn begin_channel_update<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
id: &'life0 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEditor>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Start changes to channel entry.
If the channel with the given ID exists, the ChannelEditor is returned.
Use HoprDbChannelOperations::finish_channel_update
to commit edits to the DB when done.
Sourcefn finish_channel_update<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
editor: ChannelEditor,
) -> Pin<Box<dyn Future<Output = Result<ChannelEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn finish_channel_update<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
editor: ChannelEditor,
) -> Pin<Box<dyn Future<Output = Result<ChannelEntry>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Commits changes of the channel to the database.
Sourcefn get_channel_by_parties<'a, 'life0, 'life1, 'async_trait>(
&'a self,
tx: OptTx<'a>,
src: &'life0 Address,
dst: &'life1 Address,
use_cache: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_channel_by_parties<'a, 'life0, 'life1, 'async_trait>(
&'a self,
tx: OptTx<'a>,
src: &'life0 Address,
dst: &'life1 Address,
use_cache: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves the channel by source and destination. This operation should be able to use cache since it can be also called from performance-sensitive locations.
Sourcefn get_channels_via<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
direction: ChannelDirection,
target: &'life0 Address,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_channels_via<'a, 'life0, 'async_trait>(
&'a self,
tx: OptTx<'a>,
direction: ChannelDirection,
target: &'life0 Address,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Fetches all channels that are Incoming
to the given target
, or Outgoing
from the given target
Sourcefn get_incoming_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_incoming_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Fetches all channels that are Incoming
to this node.
Shorthand for get_channels_via(tx, ChannelDirection::Incoming, my_node)
Sourcefn get_outgoing_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_outgoing_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Fetches all channels that are Incoming
to this node.
Shorthand for get_channels_via(tx, ChannelDirection::Outgoing, my_node)
Sourcefn get_all_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_all_channels<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Retrieves all channel information from the DB.
Sourcefn stream_active_channels<'a, 'async_trait>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, Result<ChannelEntry>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn stream_active_channels<'a, 'async_trait>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, Result<ChannelEntry>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Returns a stream of all channels that are Open
or PendingToClose
with an active grace period.s
Sourcefn upsert_channel<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
channel_entry: ChannelEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn upsert_channel<'a, 'async_trait>(
&'a self,
tx: OptTx<'a>,
channel_entry: ChannelEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Inserts or updates the given channel entry.