Struct iroh_rpc_client::network::P2pClient
source · pub struct P2pClient { /* private fields */ }
Implementations§
source§impl P2pClient
impl P2pClient
sourcepub async fn new(addr: P2pAddr) -> Result<Self>
pub async fn new(addr: P2pAddr) -> Result<Self>
Examples found in repository?
src/client.rs (line 109)
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
pub async fn new(cfg: Config) -> Result<Self> {
let Config {
gateway_addr,
p2p_addr,
store_addr,
channels,
} = cfg;
let gateway = if let Some(addr) = gateway_addr {
Some(
GatewayClient::new(addr)
.await
.context("Could not create gateway rpc client")?,
)
} else {
None
};
let n_channels = channels.unwrap_or(1);
let mut p2p = P2pLBClient::new();
if let Some(addr) = p2p_addr {
for _i in 0..n_channels {
let sc = P2pClient::new(addr.clone())
.await
.context("Could not create store rpc client")?;
p2p.clients.push(sc);
}
}
let mut store = StoreLBClient::new();
if let Some(addr) = store_addr {
for _i in 0..n_channels {
let sc = StoreClient::new(addr.clone())
.await
.context("Could not create store rpc client")?;
store.clients.push(sc);
}
}
Ok(Client {
gateway,
p2p,
store,
})
}
pub async fn version(&self) -> Result<String>
pub async fn local_peer_id(&self) -> Result<PeerId>
pub async fn external_addresses(&self) -> Result<Vec<Multiaddr>>
pub async fn listeners(&self) -> Result<Vec<Multiaddr>>
pub async fn fetch_bitswap(
&self,
ctx: u64,
cid: Cid,
providers: HashSet<PeerId>
) -> Result<Bytes>
pub async fn stop_session_bitswap(&self, ctx: u64) -> Result<()>
pub async fn notify_new_blocks_bitswap(
&self,
blocks: Vec<(Cid, Bytes)>
) -> Result<()>
pub async fn fetch_providers_dht(
&self,
key: &Cid
) -> Result<impl Stream<Item = Result<HashSet<PeerId>>>>
pub async fn start_providing(&self, key: &Cid) -> Result<()>
pub async fn stop_providing(&self, key: &Cid) -> Result<()>
pub async fn get_listening_addrs(&self) -> Result<(PeerId, Vec<Multiaddr>)>
pub async fn get_peers(&self) -> Result<HashMap<PeerId, Vec<Multiaddr>>>
sourcepub async fn connect(&self, peer_id: PeerId, addrs: Vec<Multiaddr>) -> Result<()>
pub async fn connect(&self, peer_id: PeerId, addrs: Vec<Multiaddr>) -> Result<()>
Attempts to connect to the given node. If only the PeerId
is present, it will
attempt to find the given peer on the DHT before connecting. If the PeerId
and any
Multiaddr
s are present, it will attempt to connect to the peer directly.
pub async fn lookup(
&self,
peer_id: PeerId,
addr: Option<Multiaddr>
) -> Result<Lookup>
pub async fn lookup_local(&self) -> Result<Lookup>
pub async fn disconnect(&self, peer_id: PeerId) -> Result<()>
pub async fn shutdown(&self) -> Result<()>
pub async fn gossipsub_add_explicit_peer(&self, peer_id: PeerId) -> Result<()>
pub async fn gossipsub_all_mesh_peers(&self) -> Result<Vec<PeerId>>
pub async fn gossipsub_all_peers(&self) -> Result<Vec<(PeerId, Vec<TopicHash>)>>
pub async fn gossipsub_mesh_peers(&self, topic: TopicHash) -> Result<Vec<PeerId>>
pub async fn gossipsub_publish(
&self,
topic_hash: TopicHash,
data: Bytes
) -> Result<MessageId>
pub async fn gossipsub_remove_explicit_peer(&self, peer_id: PeerId) -> Result<()>
pub async fn gossipsub_subscribe(&self, topic: TopicHash) -> Result<bool>
pub async fn gossipsub_topics(&self) -> Result<Vec<TopicHash>>
pub async fn gossipsub_unsubscribe(&self, topic: TopicHash) -> Result<bool>
sourcepub async fn check(&self) -> (StatusType, String)
pub async fn check(&self) -> (StatusType, String)
Examples found in repository?
src/client.rs (line 155)
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
pub async fn check(&self) -> crate::status::ClientStatus {
let g = if let Some(ref g) = self.gateway {
let (s, v) = g.check().await;
Some(ServiceStatus::new(ServiceType::Gateway, s, v))
} else {
None
};
let p = if let Some(ref p) = self.p2p.get() {
let (s, v) = p.check().await;
Some(ServiceStatus::new(ServiceType::P2p, s, v))
} else {
None
};
let s = if let Some(ref s) = self.store.get() {
let (s, v) = s.check().await;
Some(ServiceStatus::new(ServiceType::Store, s, v))
} else {
None
};
ClientStatus::new(g, p, s)
}
pub async fn watch(&self) -> impl Stream<Item = (StatusType, String)>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for P2pClient
impl Send for P2pClient
impl Sync for P2pClient
impl Unpin for P2pClient
impl !UnwindSafe for P2pClient
Blanket Implementations§
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request