mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 10:08:02 +00:00
Unnecessery clones + removed unused Enum value (#1557)
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
This commit is contained in:
committed by
Bastian Köcher
parent
793321fcfc
commit
effe0f11c8
@@ -104,7 +104,7 @@ impl TransactionSignScheme for Millau {
|
||||
|
||||
fn sign_transaction(param: SignParam<Self>) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
param.unsigned.call.clone(),
|
||||
param.unsigned.call,
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<millau_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<millau_runtime::Runtime>::new(),
|
||||
|
||||
@@ -111,7 +111,7 @@ impl TransactionSignScheme for Rialto {
|
||||
|
||||
fn sign_transaction(param: SignParam<Self>) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
param.unsigned.call.clone(),
|
||||
param.unsigned.call,
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
|
||||
|
||||
@@ -80,7 +80,7 @@ pub struct Client<C: Chain> {
|
||||
/// Tokio runtime handle.
|
||||
tokio: Arc<tokio::runtime::Runtime>,
|
||||
/// Client connection params.
|
||||
params: ConnectionParams,
|
||||
params: Arc<ConnectionParams>,
|
||||
/// Substrate RPC client.
|
||||
client: Arc<RpcClient>,
|
||||
/// Genesis block hash.
|
||||
@@ -99,7 +99,7 @@ impl<C: Chain> relay_utils::relay_loop::Client for Client<C> {
|
||||
type Error = Error;
|
||||
|
||||
async fn reconnect(&mut self) -> Result<()> {
|
||||
let (tokio, client) = Self::build_client(self.params.clone()).await?;
|
||||
let (tokio, client) = Self::build_client(&self.params).await?;
|
||||
self.tokio = tokio;
|
||||
self.client = client;
|
||||
Ok(())
|
||||
@@ -131,6 +131,7 @@ impl<C: Chain> Client<C> {
|
||||
/// This function will keep connecting to given Substrate node until connection is established
|
||||
/// and is functional. If attempt fail, it will wait for `RECONNECT_DELAY` and retry again.
|
||||
pub async fn new(params: ConnectionParams) -> Self {
|
||||
let params = Arc::new(params);
|
||||
loop {
|
||||
match Self::try_connect(params.clone()).await {
|
||||
Ok(client) => return client,
|
||||
@@ -149,8 +150,8 @@ impl<C: Chain> Client<C> {
|
||||
|
||||
/// Try to connect to Substrate node over websocket. Returns Substrate RPC client if connection
|
||||
/// has been established or error otherwise.
|
||||
pub async fn try_connect(params: ConnectionParams) -> Result<Self> {
|
||||
let (tokio, client) = Self::build_client(params.clone()).await?;
|
||||
pub async fn try_connect(params: Arc<ConnectionParams>) -> Result<Self> {
|
||||
let (tokio, client) = Self::build_client(¶ms).await?;
|
||||
|
||||
let number: C::BlockNumber = Zero::zero();
|
||||
let genesis_hash_client = client.clone();
|
||||
@@ -173,7 +174,7 @@ impl<C: Chain> Client<C> {
|
||||
|
||||
/// Build client to use in connection.
|
||||
async fn build_client(
|
||||
params: ConnectionParams,
|
||||
params: &ConnectionParams,
|
||||
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
|
||||
let tokio = tokio::runtime::Runtime::new()?;
|
||||
let uri = format!(
|
||||
|
||||
@@ -55,9 +55,6 @@ pub enum Error<Hash: Debug + MaybeDisplay, HeaderNumber: Debug + MaybeDisplay> {
|
||||
/// Failed to retrieve header by the hash from the source chain.
|
||||
#[error("Failed to retrieve {0} header with hash {1}: {:?}")]
|
||||
RetrieveHeader(&'static str, Hash, client::Error),
|
||||
/// Failed to retrieve best finalized source header hash from the target chain.
|
||||
#[error("Failed to retrieve best finalized {0} header from the target chain: {1}")]
|
||||
RetrieveBestFinalizedHeaderHash(&'static str, client::Error),
|
||||
/// Failed to submit signed extrinsic from to the target chain.
|
||||
#[error(
|
||||
"Failed to retrieve `is_initialized` flag of the with-{0} finality pallet at {1}: {2:?}"
|
||||
|
||||
Reference in New Issue
Block a user