pub trait IRawFederationApi:
Debug
+ MaybeSend
+ MaybeSync {
// Required methods
fn all_peers(&self) -> &BTreeSet<PeerId>;
fn self_peer(&self) -> Option<PeerId>;
fn with_module(&self, id: ModuleInstanceId) -> DynModuleApi;
fn request_raw<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
peer_id: PeerId,
method: &'life1 str,
params: &'life2 ApiRequestErased,
) -> Pin<Box<dyn Future<Output = ServerResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn connection_status_stream(
&self,
) -> BoxStream<'static, BTreeMap<PeerId, PeerStatus>>;
fn wait_for_initialized_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_peer_connection<'life0, 'async_trait>(
&'life0 self,
peer_id: PeerId,
) -> Pin<Box<dyn Future<Output = ServerResult<DynGuaridianConnection>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
An API (module or global) that can query a federation
Required Methods§
Sourcefn all_peers(&self) -> &BTreeSet<PeerId>
fn all_peers(&self) -> &BTreeSet<PeerId>
List of all federation peers for the purpose of iterating each peer in the federation.
The underlying implementation is responsible for knowing how many
and PeerIds of each. The caller of this interface most probably
have some idea as well, but passing this set across every
API call to the federation would be inconvenient.
Sourcefn self_peer(&self) -> Option<PeerId>
fn self_peer(&self) -> Option<PeerId>
PeerId of the Guardian node, if set
This is for using Client in a “Admin” mode, making authenticated
calls to own fedimintd instance.
fn with_module(&self, id: ModuleInstanceId) -> DynModuleApi
Sourcefn request_raw<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
peer_id: PeerId,
method: &'life1 str,
params: &'life2 ApiRequestErased,
) -> Pin<Box<dyn Future<Output = ServerResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn request_raw<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
peer_id: PeerId,
method: &'life1 str,
params: &'life2 ApiRequestErased,
) -> Pin<Box<dyn Future<Output = ServerResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Make request to a specific federation peer by peer_id
Sourcefn connection_status_stream(
&self,
) -> BoxStream<'static, BTreeMap<PeerId, PeerStatus>>
fn connection_status_stream( &self, ) -> BoxStream<'static, BTreeMap<PeerId, PeerStatus>>
Returns a stream of connection status for each peer.
The stream emits a new value whenever either the set of active connections in the pool changes, or a connector observes a transport-level path change on an existing connection (e.g. an iroh connection upgrading from relay to direct).
Each peer’s entry is PeerStatus::Disconnected if there is no
active pooled connection, or PeerStatus::Connected carrying the
current fedimint_connectors::Connectivity otherwise. If the pool
reports the peer as active but the underlying connector no longer
has a known path for it (a disconnection racing the pool update),
the peer is reported as PeerStatus::Disconnected — the next
emission will confirm.
Sourcefn wait_for_initialized_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wait_for_initialized_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Wait for some connections being initialized
This is useful to avoid initializing networking by tasks that are not high priority.
Sourcefn get_peer_connection<'life0, 'async_trait>(
&'life0 self,
peer_id: PeerId,
) -> Pin<Box<dyn Future<Output = ServerResult<DynGuaridianConnection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_peer_connection<'life0, 'async_trait>(
&'life0 self,
peer_id: PeerId,
) -> Pin<Box<dyn Future<Output = ServerResult<DynGuaridianConnection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get or create a connection to a specific peer, returning the connection object.
This can be used to monitor connection status and await disconnection for proactive reconnection strategies.