Skip to content

Commit

Permalink
connect_http_with_truststore
Browse files Browse the repository at this point in the history
  • Loading branch information
thisbefruit committed May 9, 2024
1 parent 412b326 commit 8e12aef
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
/// Global backhaul for caching connections etc
static BACKHAUL: Lazy<HttpBackhaul> = 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<Self> {
let bootstrap_routes = melbootstrap::bootstrap_routes(netid);
Expand Down

0 comments on commit 8e12aef

Please sign in to comment.