Changed how relay loops are started (#840)

* slightly changed relay loop initialization

* git mv

* clippy

* more clippy

* loop_run -> run_loop

* review and clippy

* clippy
This commit is contained in:
Svyatoslav Nikolsky
2021-03-24 11:46:30 +03:00
committed by Bastian Köcher
parent 8d122b03f1
commit a17c7eb80c
21 changed files with 379 additions and 348 deletions
@@ -385,7 +385,7 @@ async fn run_auto_transactions_relay_loop(
metrics_params,
futures::future::pending(),
)
.await;
.await?;
Ok(())
}
@@ -258,8 +258,8 @@ pub async fn run(params: EthereumSyncParams) -> Result<(), RpcError> {
instance,
} = params;
let eth_client = async_std::task::block_on(EthereumClient::new(eth_params))?;
let sub_client = async_std::task::block_on(SubstrateClient::<Rialto>::new(sub_params))?;
let eth_client = EthereumClient::new(eth_params).await?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await?;
let sign_sub_transactions = match sync_params.target_tx_mode {
TargetTransactionMode::Signed | TargetTransactionMode::Backup => true,
@@ -279,7 +279,8 @@ pub async fn run(params: EthereumSyncParams) -> Result<(), RpcError> {
metrics_params,
futures::future::pending(),
)
.await;
.await
.map_err(RpcError::SyncLoop)?;
Ok(())
}
@@ -29,6 +29,8 @@ pub enum RpcError {
Ethereum(EthereumNodeError),
/// An error occured when interacting with a Substrate node.
Substrate(SubstrateNodeError),
/// Error running relay loop.
SyncLoop(String),
}
impl From<RpcError> for String {
@@ -37,6 +39,7 @@ impl From<RpcError> for String {
RpcError::Serialization(e) => e.to_string(),
RpcError::Ethereum(e) => e.to_string(),
RpcError::Substrate(e) => e.to_string(),
RpcError::SyncLoop(e) => e,
}
}
}
@@ -173,8 +173,8 @@ pub async fn run(params: SubstrateSyncParams) -> Result<(), RpcError> {
metrics_params,
} = params;
let eth_client = async_std::task::block_on(EthereumClient::new(eth_params))?;
let sub_client = async_std::task::block_on(SubstrateClient::<Rialto>::new(sub_params))?;
let eth_client = EthereumClient::new(eth_params).await?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await?;
let target = EthereumHeadersTarget::new(eth_client, eth_contract_address, eth_sign);
let source = SubstrateHeadersSource::new(sub_client);
@@ -189,7 +189,8 @@ pub async fn run(params: SubstrateSyncParams) -> Result<(), RpcError> {
metrics_params,
futures::future::pending(),
)
.await;
.await
.map_err(RpcError::SyncLoop)?;
Ok(())
}