This commit is contained in:
Sebastian
2024-09-11 12:16:41 +02:00
parent 03eeb4737f
commit d37ac5dd93
2 changed files with 2 additions and 23 deletions

View File

@@ -29,6 +29,7 @@ for path in $pathlist; do
if [[ $http_status_code -eq 200 ]]; then if [[ $http_status_code -eq 200 ]]; then
response=$(cat "$response_file") response=$(cat "$response_file")
latest_block_number=$(echo "$response" | jq -r '.result.number') latest_block_number=$(echo "$response" | jq -r '.result.number')
latest_block_number_decimal=$((16#${latest_block_number#0x})) latest_block_number_decimal=$((16#${latest_block_number#0x}))

View File

@@ -1,19 +1,5 @@
#!/bin/bash #!/bin/bash
ms_to_human_readable() {
local ms=$1
local days=$((ms / 86400000))
ms=$((ms % 86400000))
local hours=$((ms / 3600000))
ms=$((ms % 3600000))
local minutes=$((ms / 60000))
ms=$((ms % 60000))
local seconds=$((ms / 1000))
local milliseconds=$((ms % 1000))
printf "%d days, %02d hours, %02d minutes, %02d seconds, %03d milliseconds\n" $days $hours $minutes $seconds $milliseconds
}
BASEPATH="$(dirname "$0")" BASEPATH="$(dirname "$0")"
source $BASEPATH/.env source $BASEPATH/.env
@@ -43,19 +29,11 @@ for path in $pathlist; do
if [[ $http_status_code -eq 200 ]]; then if [[ $http_status_code -eq 200 ]]; then
response=$(cat "$response_file") response=$(cat "$response_file")
latest_block_number=$(echo "$response" | jq -r '.result.number')
latest_block_number_decimal=$((16#${latest_block_number#0x}))
latest_block_timestamp=$(echo "$response" | jq -r '.result.timestamp') latest_block_timestamp=$(echo "$response" | jq -r '.result.timestamp')
latest_block_timestamp_decimal=$((16#${latest_block_timestamp#0x})) latest_block_timestamp_decimal=$((16#${latest_block_timestamp#0x}))
current_time=$(date +%s)
time_difference=$((current_time - latest_block_timestamp_decimal))
if [[ $2 == "true" ]]; then echo "$latest_block_timestamp_decimal"
ms_to_human_readable "$time_difference"
else
echo "$latest_block_number_decimal"
fi
exit 0; exit 0;
fi fi