Skip to content

Commit

Permalink
Normal interval for checks
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 25, 2023
1 parent 10ad002 commit e36c5e2
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
6 changes: 4 additions & 2 deletions config-payments.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[engine]
# proces interval (in seconds) is to set how often we want to check for transaction
process-interval = 25
# proces interval (in seconds) is to set how often we want to recheck transaction status
process-interval = 15
# proces interval after send (in seconds) is to set how long to wait after sending transaction before checking for confirmation
process-interval-after-send = 30
# proces interval after error (in seconds) is to set how long to wait after encountering error before trying again
process-interval-after-error = 25
# gather interval (in seconds) is to set how often payments are gathered
Expand Down
1 change: 1 addition & 0 deletions crates/erc20_payment_lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl AdditionalOptions {
pub struct Engine {
pub process_interval: u64,
pub process_interval_after_error: u64,
pub process_interval_after_send: u64,
pub gather_interval: u64,
pub gather_at_start: bool,
pub automatic_recover: bool,
Expand Down
1 change: 1 addition & 0 deletions crates/erc20_payment_lib/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl PaymentRuntime {
options.skip_multi_contract_check,
config.engine.process_interval,
config.engine.process_interval_after_error,
config.engine.process_interval_after_send,
config.engine.gather_interval,
config.engine.gather_at_start,
config.engine.automatic_recover,
Expand Down
5 changes: 4 additions & 1 deletion crates/erc20_payment_lib/src/sender/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ pub async fn process_transaction(
web3_tx_dao.id,
web3_tx_dao.tx_hash.clone().unwrap_or_default()
);
tokio::time::sleep(Duration::from_secs(payment_setup.process_interval)).await;
tokio::time::sleep(Duration::from_secs(
payment_setup.process_interval_after_send,
))
.await;
}

if web3_tx_dao.confirm_date.is_some() {
Expand Down
3 changes: 3 additions & 0 deletions crates/erc20_payment_lib/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct PaymentSetup {
pub skip_multi_contract_check: bool,
pub process_interval: u64,
pub process_interval_after_error: u64,
pub process_interval_after_send: u64,
pub gather_interval: u64,
pub gather_at_start: bool,
pub automatic_recover: bool,
Expand All @@ -81,6 +82,7 @@ impl PaymentSetup {
skip_multi_contract_check: bool,
process_interval: u64,
process_interval_after_error: u64,
process_interval_after_send: u64,
gather_interval: u64,
gather_at_start: bool,
automatic_recover: bool,
Expand All @@ -94,6 +96,7 @@ impl PaymentSetup {
skip_multi_contract_check,
process_interval,
process_interval_after_error,
process_interval_after_send,
gather_interval,
gather_at_start,
automatic_recover,
Expand Down
2 changes: 1 addition & 1 deletion crates/erc20_payment_lib_extra/src/account_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn account_balance(
))?;

let payment_setup =
PaymentSetup::new(config, vec![], true, false, false, 1, 1, 1, false, false)?;
PaymentSetup::new(config, vec![], true, false, false, 1, 1, 1, 1, false, false)?;

let web3 = payment_setup.get_provider(chain_cfg.chain_id)?;

Expand Down
7 changes: 4 additions & 3 deletions crates/erc20_payment_lib_test/src/config_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ pub async fn create_default_config_setup(proxy_url_base: &str, proxy_key: &str)
Config {
chain: chain_map,
engine: Engine {
process_interval: 0,
process_interval_after_error: 0,
gather_interval: 0,
process_interval: 1,
process_interval_after_error: 1,
process_interval_after_send: 1,
gather_interval: 1,
automatic_recover: false,
gather_at_start: false,
},
Expand Down
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,19 @@ async fn main_internal() -> Result<(), PaymentError> {
} => {
log::info!("Scanning blockchain {}", scan_blockchain_options.chain_name);

let payment_setup =
PaymentSetup::new(&config, vec![], true, false, false, 1, 1, 1, false, false)?;
let payment_setup = PaymentSetup::new(
&config,
vec![],
true,
false,
false,
1,
1,
1,
1,
false,
false,
)?;
let chain_cfg = config
.chain
.get(&scan_blockchain_options.chain_name)
Expand Down

0 comments on commit e36c5e2

Please sign in to comment.