Companion for #13923 (#7111)

* make staking miner compatible with new OnlineConfig

* remove dead code
This commit is contained in:
Liam Aharon
2023-04-21 18:47:12 +10:00
committed by GitHub
parent 914466fdf0
commit ac09a84115
2 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ use frame_election_provider_support::NposSolver;
use frame_support::traits::Get;
use futures_util::StreamExt;
use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use remote_externalities::{Builder, Mode, OnlineConfig};
use remote_externalities::{Builder, Mode, OnlineConfig, Transport};
use rpc::{RpcApiClient, SharedRpcClient};
use runtime_versions::RuntimeVersions;
use signal_hook::consts::signal::*;
@@ -314,7 +314,7 @@ where
pallets.extend(additional);
Builder::<B>::new()
.mode(Mode::Online(OnlineConfig {
transport: client.into_inner().into(),
transport: Transport::Uri(client.uri().to_owned()),
at,
pallets,
hashed_prefixes: vec![<frame_system::BlockHash<T>>::prefix_hash()],
+7 -5
View File
@@ -103,9 +103,11 @@ pub trait RpcApi {
fn subscribe_finalized_heads(&self);
}
type Uri = String;
/// Wraps a shared web-socket JSON-RPC client that can be cloned.
#[derive(Clone, Debug)]
pub(crate) struct SharedRpcClient(Arc<WsClient>);
pub(crate) struct SharedRpcClient(Arc<WsClient>, Uri);
impl Deref for SharedRpcClient {
type Target = WsClient;
@@ -116,9 +118,9 @@ impl Deref for SharedRpcClient {
}
impl SharedRpcClient {
/// Consume and extract the inner client.
pub fn into_inner(self) -> Arc<WsClient> {
self.0
/// Get the URI of the client.
pub fn uri(&self) -> &str {
&self.1
}
/// Create a new shared JSON-RPC web-socket client.
@@ -134,7 +136,7 @@ impl SharedRpcClient {
.max_concurrent_requests(u32::MAX as usize)
.build(uri)
.await?;
Ok(Self(Arc::new(client)))
Ok(Self(Arc::new(client), uri.to_owned()))
}
/// Get a storage item and decode it as `T`.