From 8e12aef6bbc0bbdb5fa4eafe828ab69fbd9d4569 Mon Sep 17 00:00:00 2001 From: thisbefruit Date: Thu, 9 May 2024 15:47:23 -0400 Subject: [PATCH] connect_http_with_truststore --- src/client.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/client.rs b/src/client.rs index 280beae..e7a71cc 100644 --- a/src/client.rs +++ b/src/client.rs @@ -112,6 +112,19 @@ impl Client { )) } + pub async fn connect_http_with_truststore( + netid: NetID, + addr: SocketAddr, + trust_store: impl TrustStore + Send + Sync + 'static, + ) -> anyhow::Result { + /// Global backhaul for caching connections etc + static BACKHAUL: Lazy = Lazy::new(HttpBackhaul::new); + let rpc_client = NodeRpcClient(BACKHAUL.connect(addr.to_string().into()).await?); + + // one-off set up to "trust" a custom network. + Ok(Self::new_with_truststore(netid, rpc_client, trust_store)) + } + /// A convenience method for automatically connecting a client pub async fn autoconnect(netid: NetID) -> anyhow::Result { let bootstrap_routes = melbootstrap::bootstrap_routes(netid);