Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 25, 2023
1 parent d70b1ca commit f280a3d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions config-payments.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[engine]
# proces interval (in seconds) is to set how often we want to check for transaction
process-interval = 5
process-interval = 25
# proces interval after error (in seconds) is to set how long to wait after encountering error before trying again
process-interval-after-error = 15
process-interval-after-error = 25
# gather interval (in seconds) is to set how often payments are gathered
gather-interval = 600
gather-interval = 60
# gather payments on payment driver start (otherwise wait for first gather-sleep)
gather-at-start = true
automatic-recover = false
Expand Down Expand Up @@ -49,7 +49,7 @@ currency-symbol = "tMATIC"
priority-fee = 1.0
max-fee-per-gas = 14.0
gas-left-warning-limit = 1000000
transaction-timeout = 10
transaction-timeout = 60
token = { address = "0x2036807B0B3aaf5b1858EE822D0e111fDdac7018", symbol = "tGLM" }
multi-contract = { address = "0x800010D7d0d315DCA795110ecCf0127cBd76b89f", max-at-once = 10 }
confirmation-blocks = 1
Expand Down
1 change: 1 addition & 0 deletions crates/erc20_payment_lib/src/sender/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ 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;
}

if web3_tx_dao.confirm_date.is_some() {
Expand Down
18 changes: 8 additions & 10 deletions crates/erc20_payment_lib/src/sender/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,16 @@ pub async fn process_transactions(
DriverEventContent::TransactionConfirmed(tx.clone()),
)
.await;
//proces next transaction without waiting
continue;
}
_ => {
shared_state.lock().await.current_tx_info.remove(&tx.id);
}
}

tokio::time::sleep(std::time::Duration::from_secs(
log::debug!("Sleeping for {} seconds (process interval)", payment_setup.process_interval);
tokio::time::sleep(Duration::from_secs(
payment_setup.process_interval,
))
.await;
Expand Down Expand Up @@ -382,10 +385,7 @@ pub async fn service_loop(
.await
{
log::error!("Error in process transactions: {}", e);
tokio::time::sleep(std::time::Duration::from_secs(
payment_setup.process_interval,
))
.await;
tokio::time::sleep(Duration::from_secs(payment_setup.process_interval)).await;
continue;
}

Expand All @@ -397,7 +397,7 @@ pub async fn service_loop(
last_gather_time + chrono::Duration::seconds(gather_transactions_interval);
if current_time < next_gather_time {
log::info!(
"Transaction will be gathered in {} seconds",
"Payments will be gathered in {} seconds",
humantime::format_duration(Duration::from_secs(
(next_gather_time - current_time).num_seconds() as u64
))
Expand All @@ -408,13 +408,13 @@ pub async fn service_loop(
)))
.await;
} else {
log::info!("Gathering transfers...");
log::info!("Gathering payments...");
let mut token_transfer_map = match gather_transactions_pre(conn, payment_setup).await {
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.process_interval,
payment_setup.process_interval_after_error,
))
.await;
continue;
Expand All @@ -432,8 +432,6 @@ pub async fn service_loop(
Ok(count) => {
if count > 0 {
process_tx_needed = true;
} else {
log::info!("No new transfers to process");
}
}
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/erc20_payment_lib/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ pub async fn check_transaction(
gas_est + gas_safety_margin
};

log::info!("Set gas limit basing on gas estimation: {gas_limit}");
log::debug!("Set gas limit basing on gas estimation: {gas_limit}");
web3_tx_dao.gas_limit = Some(gas_limit.as_u64() as i64);

let max_fee_per_gas = U256::from_dec_str(
Expand Down

0 comments on commit f280a3d

Please sign in to comment.