Skip to main content

HasChainApi

Trait HasChainApi 

pub trait HasChainApi {
    type ChainApi: HoprChainApi + ComponentStatusReporter + Clone + Send + Sync + 'static;
    type ChainError: Error + Send + Sync + 'static;

    // Required methods
    fn identity(&self) -> &NodeOnchainIdentity;
    fn chain_api(&self) -> &Self::ChainApi;
    fn status(&self) -> ComponentStatus;
    fn wait_for_on_chain_event<F>(
        &self,
        predicate: F,
        context: String,
        timeout: Duration,
    ) -> Result<(Pin<Box<dyn Future<Output = Result<ChainEvent, EitherErr<<Self::ChainApi as HoprChainApi>::ChainError, Self::ChainError>>> + Send>>, AbortHandle), <Self::ChainApi as HoprChainApi>::ChainError>
       where F: Fn(&ChainEvent) -> bool + Send + Sync + 'static;
}
Expand description

Provides access to the chain component of a HOPR node.

Required Associated Types§

type ChainApi: HoprChainApi + ComponentStatusReporter + Clone + Send + Sync + 'static

The concrete chain API implementation.

type ChainError: Error + Send + Sync + 'static

Error type for node-level chain operations (distinct from on-chain errors).

Required Methods§

fn identity(&self) -> &NodeOnchainIdentity

Returns the node’s on-chain identity (node address, Safe address, module address).

fn chain_api(&self) -> &Self::ChainApi

Returns a reference to the underlying chain API.

fn status(&self) -> ComponentStatus

Reports the current health of the chain component.

fn wait_for_on_chain_event<F>( &self, predicate: F, context: String, timeout: Duration, ) -> Result<(Pin<Box<dyn Future<Output = Result<ChainEvent, EitherErr<<Self::ChainApi as HoprChainApi>::ChainError, Self::ChainError>>> + Send>>, AbortHandle), <Self::ChainApi as HoprChainApi>::ChainError>
where F: Fn(&ChainEvent) -> bool + Send + Sync + 'static,

Spawns an asynchronous waiter that subscribes to ChainEvents and resolves when predicate matches or timeout elapses.

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.

Implementations on Foreign Types§

§

impl<'a, T> HasChainApi for &'a T
where T: 'a + HasChainApi + ?Sized,

§

type ChainApi = <T as HasChainApi>::ChainApi

§

type ChainError = <T as HasChainApi>::ChainError

§

fn identity(&self) -> &NodeOnchainIdentity

§

fn chain_api(&self) -> &<&'a T as HasChainApi>::ChainApi

§

fn status(&self) -> ComponentStatus

§

fn wait_for_on_chain_event<F>( &self, predicate: F, context: String, timeout: Duration, ) -> Result<(Pin<Box<dyn Future<Output = Result<ChainEvent, EitherErr<<<&'a T as HasChainApi>::ChainApi as HoprChainApi>::ChainError, <&'a T as HasChainApi>::ChainError>>> + Send>>, AbortHandle), <<&'a T as HasChainApi>::ChainApi as HoprChainApi>::ChainError>
where F: Fn(&ChainEvent) -> bool + Send + Sync + 'static,

§

impl<T> HasChainApi for Arc<T>
where T: HasChainApi + ?Sized,

§

type ChainApi = <T as HasChainApi>::ChainApi

§

type ChainError = <T as HasChainApi>::ChainError

§

fn identity(&self) -> &NodeOnchainIdentity

§

fn chain_api(&self) -> &<Arc<T> as HasChainApi>::ChainApi

§

fn status(&self) -> ComponentStatus

§

fn wait_for_on_chain_event<F>( &self, predicate: F, context: String, timeout: Duration, ) -> Result<(Pin<Box<dyn Future<Output = Result<ChainEvent, EitherErr<<<Arc<T> as HasChainApi>::ChainApi as HoprChainApi>::ChainError, <Arc<T> as HasChainApi>::ChainError>>> + Send>>, AbortHandle), <<Arc<T> as HasChainApi>::ChainApi as HoprChainApi>::ChainError>
where F: Fn(&ChainEvent) -> bool + Send + Sync + 'static,

Implementors§

Source§

impl<Chain, Graph, Net, TMgr> HasChainApi for Hopr<Chain, Graph, Net, TMgr>
where Chain: HoprChainApi + ComponentStatusReporter + Clone + Send + Sync + 'static,