diff --git a/examples/examples/custom_rpc_client.rs b/examples/examples/custom_rpc_client.rs index 9329b67aad57b..52e0cd82275b3 100644 --- a/examples/examples/custom_rpc_client.rs +++ b/examples/examples/custom_rpc_client.rs @@ -88,7 +88,7 @@ async fn main() -> Result<(), Box> { // Pass this into our OnlineClient to instantiate it. This will lead to some // RPC calls being made to fetch chain details/metadata, which will immediately // fail.. - let _ = OnlineClient::::from_rpc_client(rpc_client).await; + let _ = OnlineClient::::from_rpc_client(Arc::new(rpc_client)).await; // But, we can see that the calls were made via our custom RPC client: println!("Log of calls made:\n\n{}", log.lock().unwrap().as_str()); diff --git a/subxt/src/client/online_client.rs b/subxt/src/client/online_client.rs index d043edf7d1662..3fe6ca1ca28f3 100644 --- a/subxt/src/client/online_client.rs +++ b/subxt/src/client/online_client.rs @@ -74,7 +74,7 @@ impl OnlineClient { let client = jsonrpsee_helpers::ws_client(url.as_ref()) .await .map_err(|e| crate::error::RpcError(e.to_string()))?; - OnlineClient::from_rpc_client(client).await + OnlineClient::from_rpc_client(Arc::new(client)).await } } @@ -82,7 +82,7 @@ impl OnlineClient { /// Construct a new [`OnlineClient`] by providing an underlying [`RpcClientT`] /// implementation to drive the connection. pub async fn from_rpc_client( - rpc_client: R, + rpc_client: Arc, ) -> Result, Error> { let rpc = Rpc::new(rpc_client); diff --git a/subxt/src/events/mod.rs b/subxt/src/events/mod.rs index d0c9ba0f5b2e7..2019253e0b55e 100644 --- a/subxt/src/events/mod.rs +++ b/subxt/src/events/mod.rs @@ -17,7 +17,6 @@ pub use event_subscription::{ FinalizedEventSub, }; pub use events_client::{ - // Exposed only for testing: subscribe_to_block_headers_filling_in_gaps, EventsClient, }; diff --git a/subxt/src/rpc/rpc.rs b/subxt/src/rpc/rpc.rs index cc650bea69674..f8f54823df226 100644 --- a/subxt/src/rpc/rpc.rs +++ b/subxt/src/rpc/rpc.rs @@ -76,7 +76,10 @@ use sp_runtime::{ }, ApplyExtrinsicResult, }; -use std::collections::HashMap; +use std::{ + collections::HashMap, + sync::Arc, +}; /// A number type that can be serialized both as a number or a string that encodes a number in a /// string. @@ -342,7 +345,7 @@ impl std::ops::Deref for Rpc { impl Rpc { /// Create a new [`Rpc`] - pub fn new(client: R) -> Self { + pub fn new(client: Arc) -> Self { Self { client: RpcClient::new(client), _marker: PhantomDataSendSync::new(), diff --git a/subxt/src/rpc/rpc_client.rs b/subxt/src/rpc/rpc_client.rs index 96560c60b7756..56592c03631b4 100644 --- a/subxt/src/rpc/rpc_client.rs +++ b/subxt/src/rpc/rpc_client.rs @@ -31,8 +31,8 @@ use std::{ pub struct RpcClient(Arc); impl RpcClient { - pub(crate) fn new(client: R) -> Self { - RpcClient(Arc::new(client)) + pub(crate) fn new(client: Arc) -> Self { + RpcClient(client) } /// Make an RPC request, given a method name and some parameters.