HoprDbChannelOperations

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<Option<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_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_channels<'a, 'life0, 'async_trait, T>(
        &'a self,
        source: Option<Address>,
        destination: Option<Address>,
        states: &'life0 [ChannelStatusDiscriminants],
        closure_range: T,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, ChannelEntry>>> + Send + 'async_trait>>
       where T: 'async_trait + RangeBounds<DateTime<Utc>> + Send,
             Self: 'async_trait,
             'a: 'async_trait,
             'life0: '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<Option<ChannelEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Commits changes of the channel to the database. Returns the updated channel, or on deletion, the deleted channel entry.

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_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 Outgoing from 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 channels information from the DB.

Source

fn stream_channels<'a, 'life0, 'async_trait, T>( &'a self, source: Option<Address>, destination: Option<Address>, states: &'life0 [ChannelStatusDiscriminants], closure_range: T, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'a, ChannelEntry>>> + Send + 'async_trait>>
where T: 'async_trait + RangeBounds<DateTime<Utc>> + Send, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§