Skip to content

Commit 5c8880a

Browse files
Rename tics to elapsed intervals
1 parent 1efa0b3 commit 5c8880a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

alerts/periodic_sender.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,53 @@ function fetch_gas_price() {
2424

2525
source "$ENV_FILE"
2626

27-
# Each tic lasts for 30 minutes
27+
# Each elapsed interval lasts for 30 minutes
2828
sleep_time=1800
29-
tic=0
29+
elapsed_intervals=0
3030

3131
while true; do
32-
echo "Starting pass #$tic"
32+
echo "Starting pass #$elapsed_intervals"
3333

3434
current_gas_price=$(fetch_gas_price)
3535
if [[ -z "$current_gas_price" || "$current_gas_price" == "0" ]]; then
3636
echo "Failed to fetch current gas price from both RPC URLs, skipping this pass."
3737

38-
tic=$((tic + 1))
38+
elapsed_intervals=$((elapsed_intervals + 1))
3939

4040
echo "Sleeping $sleep_time seconds (($((sleep_time / 60)) minutes))"
4141
sleep "$sleep_time"
4242
continue
4343
fi
4444
echo "Current gas price: $current_gas_price wei"
4545

46-
# In case current tic and gas price meet the criteria, send a proof and reset tic counter
47-
if { [ $tic -ge 10 ] && [ $tic -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then
48-
# Between 10 and 14 tics (5 to 7 hours), if gas price is below 2 gwei, send a proof
49-
message="Sending proof at tic $tic with gas price $current_gas_price wei"
46+
# In case current and gas price meet the criteria, send a proof and reset counter
47+
if { [ $elapsed_intervals -ge 10 ] && [ $elapsed_intervals -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then
48+
# Between 10 and 14 elapsed intervals (5 to 7 hours), if gas price is below 2 gwei, send a proof
49+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5050
echo "$message"
5151
./alerts/sender_with_alert.sh "$ENV_FILE"
52-
tic=0
53-
elif { [ $tic -ge 14 ] && [ $tic -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then
54-
# Between 14 and 16 tics (7 to 8 hours), if gas price is below 5 gwei, send a proof
55-
message="Sending proof at tic $tic with gas price $current_gas_price wei"
52+
elapsed_intervals=0
53+
elif { [ $elapsed_intervals -ge 14 ] && [ $elapsed_intervals -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then
54+
# Between 14 and 16 elapsed intervals (7 to 8 hours), if gas price is below 5 gwei, send a proof
55+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
5656
echo "$message"
5757
./alerts/sender_with_alert.sh "$ENV_FILE"
58-
tic=0
59-
elif { [ $tic -ge 16 ] && [ $tic -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then
60-
# Between 16 and 24 tics (8 to 12 hours), if gas price is below 15 gwei, send a proof
61-
message="Sending proof at tic $tic with gas price $current_gas_price wei"
58+
elapsed_intervals=0
59+
elif { [ $elapsed_intervals -ge 16 ] && [ $elapsed_intervals -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then
60+
# Between 16 and 24 elapsed intervals (8 to 12 hours), if gas price is below 15 gwei, send a proof
61+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6262
echo "$message"
6363
./alerts/sender_with_alert.sh "$ENV_FILE"
64-
tic=0
65-
elif { [ $tic -ge 50 ]; }; then
66-
# After 50 tics (25 hours), if gas price is below 50 gwei, send a proof
67-
message="Sending proof at tic $tic with gas price $current_gas_price wei"
64+
elapsed_intervals=0
65+
elif { [ $elapsed_intervals -ge 50 ]; }; then
66+
# After 50 elapsed intervals (25 hours), if gas price is below 50 gwei, send a proof
67+
message="Sending proof at $elapsed_intervals with gas price $current_gas_price wei"
6868
echo "$message"
6969
./alerts/sender_with_alert.sh "$ENV_FILE"
70-
tic=0
70+
elapsed_intervals=0
7171
fi
7272

73-
tic=$((tic + 1))
73+
elapsed_intervals=$((elapsed_intervals + 1))
7474

7575
echo "Sleeping $sleep_time seconds (($((sleep_time / 60)) minutes))"
7676
sleep "$sleep_time"

0 commit comments

Comments
 (0)