mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 06:45:41 +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> {
|
fn sign_transaction(param: SignParam<Self>) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||||
let raw_payload = SignedPayload::from_raw(
|
let raw_payload = SignedPayload::from_raw(
|
||||||
param.unsigned.call.clone(),
|
param.unsigned.call,
|
||||||
(
|
(
|
||||||
frame_system::CheckNonZeroSender::<millau_runtime::Runtime>::new(),
|
frame_system::CheckNonZeroSender::<millau_runtime::Runtime>::new(),
|
||||||
frame_system::CheckSpecVersion::<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> {
|
fn sign_transaction(param: SignParam<Self>) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||||
let raw_payload = SignedPayload::from_raw(
|
let raw_payload = SignedPayload::from_raw(
|
||||||
param.unsigned.call.clone(),
|
param.unsigned.call,
|
||||||
(
|
(
|
||||||
frame_system::CheckNonZeroSender::<rialto_runtime::Runtime>::new(),
|
frame_system::CheckNonZeroSender::<rialto_runtime::Runtime>::new(),
|
||||||
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
|
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ pub struct Client<C: Chain> {
|
|||||||
/// Tokio runtime handle.
|
/// Tokio runtime handle.
|
||||||
tokio: Arc<tokio::runtime::Runtime>,
|
tokio: Arc<tokio::runtime::Runtime>,
|
||||||
/// Client connection params.
|
/// Client connection params.
|
||||||
params: ConnectionParams,
|
params: Arc<ConnectionParams>,
|
||||||
/// Substrate RPC client.
|
/// Substrate RPC client.
|
||||||
client: Arc<RpcClient>,
|
client: Arc<RpcClient>,
|
||||||
/// Genesis block hash.
|
/// Genesis block hash.
|
||||||
@@ -99,7 +99,7 @@ impl<C: Chain> relay_utils::relay_loop::Client for Client<C> {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
async fn reconnect(&mut self) -> Result<()> {
|
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.tokio = tokio;
|
||||||
self.client = client;
|
self.client = client;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -131,6 +131,7 @@ impl<C: Chain> Client<C> {
|
|||||||
/// This function will keep connecting to given Substrate node until connection is established
|
/// 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.
|
/// and is functional. If attempt fail, it will wait for `RECONNECT_DELAY` and retry again.
|
||||||
pub async fn new(params: ConnectionParams) -> Self {
|
pub async fn new(params: ConnectionParams) -> Self {
|
||||||
|
let params = Arc::new(params);
|
||||||
loop {
|
loop {
|
||||||
match Self::try_connect(params.clone()).await {
|
match Self::try_connect(params.clone()).await {
|
||||||
Ok(client) => return client,
|
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
|
/// Try to connect to Substrate node over websocket. Returns Substrate RPC client if connection
|
||||||
/// has been established or error otherwise.
|
/// has been established or error otherwise.
|
||||||
pub async fn try_connect(params: ConnectionParams) -> Result<Self> {
|
pub async fn try_connect(params: Arc<ConnectionParams>) -> Result<Self> {
|
||||||
let (tokio, client) = Self::build_client(params.clone()).await?;
|
let (tokio, client) = Self::build_client(¶ms).await?;
|
||||||
|
|
||||||
let number: C::BlockNumber = Zero::zero();
|
let number: C::BlockNumber = Zero::zero();
|
||||||
let genesis_hash_client = client.clone();
|
let genesis_hash_client = client.clone();
|
||||||
@@ -173,7 +174,7 @@ impl<C: Chain> Client<C> {
|
|||||||
|
|
||||||
/// Build client to use in connection.
|
/// Build client to use in connection.
|
||||||
async fn build_client(
|
async fn build_client(
|
||||||
params: ConnectionParams,
|
params: &ConnectionParams,
|
||||||
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
|
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
|
||||||
let tokio = tokio::runtime::Runtime::new()?;
|
let tokio = tokio::runtime::Runtime::new()?;
|
||||||
let uri = format!(
|
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.
|
/// Failed to retrieve header by the hash from the source chain.
|
||||||
#[error("Failed to retrieve {0} header with hash {1}: {:?}")]
|
#[error("Failed to retrieve {0} header with hash {1}: {:?}")]
|
||||||
RetrieveHeader(&'static str, Hash, client::Error),
|
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.
|
/// Failed to submit signed extrinsic from to the target chain.
|
||||||
#[error(
|
#[error(
|
||||||
"Failed to retrieve `is_initialized` flag of the with-{0} finality pallet at {1}: {2:?}"
|
"Failed to retrieve `is_initialized` flag of the with-{0} finality pallet at {1}: {2:?}"
|
||||||
|
|||||||
Reference in New Issue
Block a user