hopr_db_sql::channels

Trait HoprDbChannelOperations

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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)

Source

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)

Source

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.

Source

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

Source

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.

Implementors§