|
1 | 1 | #!/bin/bash |
2 | | -# This script is responsible for the infinite loop and the sleep between passes. |
3 | | -# It forwards the path of the .env file as the first argument to action.sh |
| 2 | +# This script is responsible for the handling of periodic sending, and the clauses for sending proofs. |
| 3 | +# It forwards the path of the .env file as the first argument to the sender_with_alert.sh script when |
| 4 | +# the conditions are met. |
4 | 5 |
|
5 | 6 | ENV_FILE="$1" |
6 | 7 |
|
@@ -28,31 +29,31 @@ while true; do |
28 | 29 | current_gas_price=$(fetch_gas_price) |
29 | 30 | echo "Current gas price: $current_gas_price wei" |
30 | 31 |
|
31 | | - # Conditions for sending proofs: |
| 32 | + # In case current tic and gas price meet the criteria, send a proof and reset tic counter |
32 | 33 | if { [ $tic -ge 10 ] && [ $tic -lt 14 ] && [ $current_gas_price -lt 2000000000 ]; }; then |
33 | | - # - Between 10 and 14 tics (5 to 7 hours), if gas price is below 2 gwei, send a proof |
| 34 | + # Between 10 and 14 tics (5 to 7 hours), if gas price is below 2 gwei, send a proof |
34 | 35 | message="Sending proof at tic $tic with gas price $current_gas_price wei" |
35 | 36 | echo "$message" |
36 | 37 | ./alerts/sender_with_alert.sh "$ENV_FILE" |
37 | | - tic=0 # Reset tic counter after sending a proof |
| 38 | + tic=0 |
38 | 39 | elif { [ $tic -ge 14 ] && [ $tic -lt 16 ] && [ $current_gas_price -lt 5000000000 ]; }; then |
39 | | - # - Between 14 and 16 tics (7 to 8 hours), if gas price is below 5 gwei, send a proof |
| 40 | + # Between 14 and 16 tics (7 to 8 hours), if gas price is below 5 gwei, send a proof |
40 | 41 | message="Sending proof at tic $tic with gas price $current_gas_price wei" |
41 | 42 | echo "$message" |
42 | 43 | ./alerts/sender_with_alert.sh "$ENV_FILE" |
43 | | - tic=0 # Reset tic counter after sending a proof |
| 44 | + tic=0 |
44 | 45 | elif { [ $tic -ge 16 ] && [ $tic -lt 24 ] && [ $current_gas_price -lt 15000000000 ]; }; then |
45 | | - # - Between 16 and 24 tics (8 to 12 hours), if gas price is below 15 gwei, send a proof |
| 46 | + # Between 16 and 24 tics (8 to 12 hours), if gas price is below 15 gwei, send a proof |
46 | 47 | message="Sending proof at tic $tic with gas price $current_gas_price wei" |
47 | 48 | echo "$message" |
48 | 49 | ./alerts/sender_with_alert.sh "$ENV_FILE" |
49 | | - tic=0 # Reset tic counter after sending a proof |
| 50 | + tic=0 |
50 | 51 | elif { [ $tic -ge 50 ]; }; then |
51 | | - # - After 50 tics (25 hours), if gas price is below 50 gwei, send a proof |
| 52 | + # After 50 tics (25 hours), if gas price is below 50 gwei, send a proof |
52 | 53 | message="Sending proof at tic $tic with gas price $current_gas_price wei" |
53 | 54 | echo "$message" |
54 | 55 | ./alerts/sender_with_alert.sh "$ENV_FILE" |
55 | | - tic=0 # Reset tic counter after sending a proof |
| 56 | + tic=0 |
56 | 57 | fi |
57 | 58 |
|
58 | 59 | tic=$((tic + 1)) |
|
0 commit comments