From d9fb049cfd20169888082526a76b9d2471f43437 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 25 Oct 2023 13:50:29 +0200 Subject: [PATCH] fix time names --- config-payments.toml | 8 ++++---- crates/erc20_payment_lib/src/config.rs | 4 ++-- crates/erc20_payment_lib/src/runtime.rs | 4 ++-- crates/erc20_payment_lib/src/sender/process.rs | 10 +++++----- crates/erc20_payment_lib/src/sender/service.rs | 6 +++--- crates/erc20_payment_lib/src/service.rs | 2 +- crates/erc20_payment_lib/src/setup.rs | 12 ++++++------ crates/erc20_payment_lib/src/utils.rs | 2 +- crates/erc20_payment_lib_test/src/config_setup.rs | 4 ++-- src/options.rs | 4 ++-- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/config-payments.toml b/config-payments.toml index 4fdb56b2..e9ad210e 100644 --- a/config-payments.toml +++ b/config-payments.toml @@ -1,8 +1,8 @@ [engine] -# service sleep is for internal runtime checks -service-sleep = 5 -# process sleep is to set how often payments are gathered -gather-sleep = 600 +# proces interval (in seconds) is to set how often we want to check for transaction +process-interval = 5 +# gather interval (in seconds) is to set how often payments are gathered +gather-interval = 600 # gather payments on payment driver start (otherwise wait for first gather-sleep) gather-at-start = true automatic-recover = false diff --git a/crates/erc20_payment_lib/src/config.rs b/crates/erc20_payment_lib/src/config.rs index bbafdfa7..234b214f 100644 --- a/crates/erc20_payment_lib/src/config.rs +++ b/crates/erc20_payment_lib/src/config.rs @@ -46,8 +46,8 @@ impl AdditionalOptions { #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "kebab-case")] pub struct Engine { - pub service_sleep: u64, - pub gather_sleep: u64, + pub process_interval: u64, + pub gather_interval: u64, pub gather_at_start: bool, pub automatic_recover: bool, } diff --git a/crates/erc20_payment_lib/src/runtime.rs b/crates/erc20_payment_lib/src/runtime.rs index 764dacdf..a7365ca5 100644 --- a/crates/erc20_payment_lib/src/runtime.rs +++ b/crates/erc20_payment_lib/src/runtime.rs @@ -362,8 +362,8 @@ impl PaymentRuntime { !options.keep_running, options.generate_tx_only, options.skip_multi_contract_check, - config.engine.service_sleep, - config.engine.gather_sleep, + config.engine.process_interval, + config.engine.gather_interval, config.engine.gather_at_start, config.engine.automatic_recover, )?; diff --git a/crates/erc20_payment_lib/src/sender/process.rs b/crates/erc20_payment_lib/src/sender/process.rs index 2eafab5b..713ecf4b 100644 --- a/crates/erc20_payment_lib/src/sender/process.rs +++ b/crates/erc20_payment_lib/src/sender/process.rs @@ -59,7 +59,7 @@ pub async fn process_transaction( ) -> Result<(TxDao, ProcessTransactionResult), PaymentError> { const CHECKS_UNTIL_NOT_FOUND: u64 = 5; - let gather_sleep = Duration::from_secs(payment_setup.gather_sleep); + let gather_interval = Duration::from_secs(payment_setup.gather_interval); let chain_id = web3_tx_dao.chain_id; let Some(chain_setup) = payment_setup.chain_setup.get(&chain_id) else { @@ -766,9 +766,9 @@ pub async fn process_transaction( update_tx(conn, web3_tx_dao).await.map_err(err_from!())?; log::warn!( "Sleeping for {} seconds (process sleep after transaction send)", - gather_sleep.as_secs() + gather_interval.as_secs() ); - tokio::time::sleep(gather_sleep).await; + tokio::time::sleep(gather_interval).await; continue; } else { //timeout transaction when it is not confirmed after transaction_timeout seconds @@ -848,8 +848,8 @@ pub async fn process_transaction( } log::warn!( "Sleeping for {} seconds (process sleep at the end of the loop)", - gather_sleep.as_secs() + gather_interval.as_secs() ); - tokio::time::sleep(gather_sleep).await; + tokio::time::sleep(gather_interval).await; } } diff --git a/crates/erc20_payment_lib/src/sender/service.rs b/crates/erc20_payment_lib/src/sender/service.rs index bd59a2a8..2649b85a 100644 --- a/crates/erc20_payment_lib/src/sender/service.rs +++ b/crates/erc20_payment_lib/src/sender/service.rs @@ -343,7 +343,7 @@ pub async fn process_transactions( } } - tokio::time::sleep(std::time::Duration::from_secs(payment_setup.service_sleep)).await; + tokio::time::sleep(std::time::Duration::from_secs(payment_setup.process_interval)).await; } Ok(()) } @@ -355,7 +355,7 @@ pub async fn service_loop( signer: impl Signer + Send + Sync + 'static, event_sender: Option>, ) { - let gather_transactions_interval = payment_setup.gather_sleep as i64; + let gather_transactions_interval = payment_setup.gather_interval as i64; let mut last_gather_time = if payment_setup.gather_at_start { chrono::Utc::now() - chrono::Duration::seconds(gather_transactions_interval) } else { @@ -407,7 +407,7 @@ pub async fn service_loop( Ok(token_transfer_map) => token_transfer_map, Err(e) => { log::error!("Error in gather transactions, driver will be stuck, Fix DB to continue {:?}", e); - tokio::time::sleep(std::time::Duration::from_secs(payment_setup.service_sleep)) + tokio::time::sleep(std::time::Duration::from_secs(payment_setup.process_interval)) .await; continue; } diff --git a/crates/erc20_payment_lib/src/service.rs b/crates/erc20_payment_lib/src/service.rs index f4d2eca6..27a5c99f 100644 --- a/crates/erc20_payment_lib/src/service.rs +++ b/crates/erc20_payment_lib/src/service.rs @@ -229,6 +229,6 @@ pub async fn confirm_loop( payment_setup: &PaymentSetup, ) { loop { - tokio::time::sleep(std::time::Duration::from_secs(payment_setup.service_sleep)).await; + tokio::time::sleep(std::time::Duration::from_secs(payment_setup.process_interval)).await; } } diff --git a/crates/erc20_payment_lib/src/setup.rs b/crates/erc20_payment_lib/src/setup.rs index 74258170..07353ce1 100644 --- a/crates/erc20_payment_lib/src/setup.rs +++ b/crates/erc20_payment_lib/src/setup.rs @@ -60,8 +60,8 @@ pub struct PaymentSetup { pub finish_when_done: bool, pub generate_tx_only: bool, pub skip_multi_contract_check: bool, - pub service_sleep: u64, - pub gather_sleep: u64, + pub process_interval: u64, + pub gather_interval: u64, pub gather_at_start: bool, pub automatic_recover: bool, pub contract_use_direct_method: bool, @@ -78,8 +78,8 @@ impl PaymentSetup { finish_when_done: bool, generate_txs_only: bool, skip_multi_contract_check: bool, - service_sleep: u64, - gather_sleep: u64, + process_interval: u64, + gather_interval: u64, gather_at_start: bool, automatic_recover: bool, ) -> Result { @@ -90,8 +90,8 @@ impl PaymentSetup { finish_when_done, generate_tx_only: generate_txs_only, skip_multi_contract_check, - service_sleep, - gather_sleep, + process_interval, + gather_interval, gather_at_start, automatic_recover, contract_use_direct_method: false, diff --git a/crates/erc20_payment_lib/src/utils.rs b/crates/erc20_payment_lib/src/utils.rs index b168c0c6..34784fa0 100644 --- a/crates/erc20_payment_lib/src/utils.rs +++ b/crates/erc20_payment_lib/src/utils.rs @@ -24,7 +24,7 @@ pub fn get_env_bool_value(env_name: &str) -> bool { }) .unwrap_or(false) } - + #[derive(Debug, Clone)] pub struct ConversionError { pub msg: String, diff --git a/crates/erc20_payment_lib_test/src/config_setup.rs b/crates/erc20_payment_lib_test/src/config_setup.rs index bba7a7b6..197bffad 100644 --- a/crates/erc20_payment_lib_test/src/config_setup.rs +++ b/crates/erc20_payment_lib_test/src/config_setup.rs @@ -39,8 +39,8 @@ pub async fn create_default_config_setup(proxy_url_base: &str, proxy_key: &str) Config { chain: chain_map, engine: Engine { - service_sleep: 1, - gather_sleep: 1, + process_interval: 1, + gather_interval: 1, automatic_recover: false, gather_at_start: false, }, diff --git a/src/options.rs b/src/options.rs index 4a95508e..0eaa23de 100644 --- a/src/options.rs +++ b/src/options.rs @@ -36,14 +36,14 @@ pub struct RunOptions { help = "Sleep time between service loops in seconds", default_value = "10" )] - pub service_sleep: u64, + pub process_interval: u64, #[structopt( long = "process-sleep", help = "Sleep time between process loops in seconds", default_value = "10" )] - pub gather_sleep: u64, + pub gather_interval: u64, #[structopt(long = "http", help = "Enable http server")] pub http: bool,