in auto-relays keep trying to connect to nodes until connection is established (#971)

This commit is contained in:
Svyatoslav Nikolsky
2021-05-18 16:35:41 +03:00
committed by Bastian Köcher
parent ea82ad67cf
commit f8f8f42a89
9 changed files with 62 additions and 18 deletions
@@ -60,8 +60,8 @@ pub async fn run(params: EthereumDeployContractParams) {
} = params;
let result = async move {
let eth_client = EthereumClient::new(eth_params).await.map_err(RpcError::Ethereum)?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await.map_err(RpcError::Substrate)?;
let eth_client = EthereumClient::try_connect(eth_params).await.map_err(RpcError::Ethereum)?;
let sub_client = SubstrateClient::<Rialto>::try_connect(sub_params).await.map_err(RpcError::Substrate)?;
let (initial_header_id, initial_header) = prepare_initial_header(&sub_client, sub_initial_header).await?;
let initial_set_id = sub_initial_authorities_set_id.unwrap_or(0);
@@ -335,8 +335,10 @@ async fn run_single_transaction_relay(params: EthereumExchangeParams, eth_tx_has
..
} = params;
let eth_client = EthereumClient::new(eth_params).await.map_err(RpcError::Ethereum)?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params)
let eth_client = EthereumClient::try_connect(eth_params)
.await
.map_err(RpcError::Ethereum)?;
let sub_client = SubstrateClient::<Rialto>::try_connect(sub_params)
.await
.map_err(RpcError::Substrate)?;
@@ -363,12 +365,8 @@ async fn run_auto_transactions_relay_loop(
..
} = params;
let eth_client = EthereumClient::new(eth_params)
.await
.map_err(|err| format!("Error starting Ethereum client: {:?}", err))?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params)
.await
.map_err(|err| format!("Error starting Substrate client: {:?}", err))?;
let eth_client = EthereumClient::new(eth_params).await;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await;
let eth_start_with_block_number = match eth_start_with_block_number {
Some(eth_start_with_block_number) => eth_start_with_block_number,
@@ -52,7 +52,7 @@ pub async fn run(params: EthereumExchangeSubmitParams) {
} = params;
let result: Result<_, String> = async move {
let eth_client = EthereumClient::new(eth_params)
let eth_client = EthereumClient::try_connect(eth_params)
.await
.map_err(|err| format!("error connecting to Ethereum node: {:?}", err))?;
@@ -270,8 +270,8 @@ pub async fn run(params: EthereumSyncParams) -> Result<(), RpcError> {
instance,
} = params;
let eth_client = EthereumClient::new(eth_params).await?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await?;
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,
@@ -177,8 +177,8 @@ pub async fn run(params: SubstrateSyncParams) -> Result<(), RpcError> {
metrics_params,
} = params;
let eth_client = EthereumClient::new(eth_params).await?;
let sub_client = SubstrateClient::<Rialto>::new(sub_params).await?;
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);