calculate catchup time
This commit is contained in:
40
catchup.sh
40
catchup.sh
@@ -1,38 +1,44 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ms_to_human_readable() {
|
s_to_human_readable() {
|
||||||
local ms=$1
|
local ms=$1
|
||||||
local days=$((ms / 86400000))
|
local days=$((ms / 86400))
|
||||||
ms=$((ms % 86400000))
|
ms=$((ms % 86400))
|
||||||
local hours=$((ms / 3600000))
|
local hours=$((ms / 3600))
|
||||||
ms=$((ms % 3600000))
|
ms=$((ms % 3600))
|
||||||
local minutes=$((ms / 60000))
|
local minutes=$((ms / 60))
|
||||||
ms=$((ms % 60000))
|
ms=$((ms % 60))
|
||||||
local seconds=$((ms / 1000))
|
local seconds=$((ms % 60))
|
||||||
local milliseconds=$((ms % 1000))
|
|
||||||
|
|
||||||
printf "%d days, %02d hours, %02d minutes, %02d seconds, %03d milliseconds\n" $days $hours $minutes $seconds $milliseconds
|
printf "%d days, %02d hours, %02d minutes, %02d seconds\n" $days $hours $minutes $seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
BASEPATH="$(dirname "$0")"
|
BASEPATH="$(dirname "$0")"
|
||||||
source $BASEPATH/.env
|
source $BASEPATH/.env
|
||||||
|
|
||||||
|
seconds_to_measure=10
|
||||||
|
|
||||||
latest_block_timestamp_decimal=$(./timestamp.sh $1)
|
latest_block_timestamp_decimal=$(./timestamp.sh $1)
|
||||||
current_time=$(date +%s)
|
current_time=$(date +%s)
|
||||||
time_difference=$((current_time - latest_block_timestamp_decimal))
|
time_difference=$((current_time - latest_block_timestamp_decimal))
|
||||||
|
|
||||||
ms_to_human_readable $time_difference
|
#echo "$latest_block_timestamp_decimal $current_time $time_difference"
|
||||||
|
|
||||||
|
#s_to_human_readable $time_difference
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
latest_block_timestamp_decimal=$(./timestamp.sh $1)
|
latest_block_timestamp_decimal=$(./timestamp.sh $1)
|
||||||
current_time=$(date +%s)
|
current_time=$(date +%s)
|
||||||
time_difference2=$((current_time - latest_block_timestamp_decimal))
|
time_difference2=$((current_time - latest_block_timestamp_decimal))
|
||||||
|
|
||||||
ms_to_human_readable $time_difference2
|
#echo "$latest_block_timestamp_decimal $current_time $time_difference2"
|
||||||
|
|
||||||
|
#s_to_human_readable $time_difference2
|
||||||
progress=$((time_difference - time_difference2))
|
progress=$((time_difference - time_difference2))
|
||||||
|
progress_per_second=$((progress / seconds_to_measure))
|
||||||
|
#echo "$progress_per_second"
|
||||||
|
#s_to_human_readable $progress_per_second
|
||||||
|
|
||||||
ms_to_human_readable $progress
|
result=$(echo "scale=0; $time_difference2 / $progress_per_second" | bc)
|
||||||
|
#echo "$result"
|
||||||
result=$(echo "scale=0; $latest_block_timestamp_decimal / ($progress * 6)" | bc)
|
s_to_human_readable $result
|
||||||
|
|
||||||
ms_to_human_readable $(($result*60*1000))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user