almost
This commit is contained in:
@@ -22,15 +22,17 @@ for path in $pathlist; do
|
|||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
|
||||||
if [[ $http_status_code -eq 200 ]]; then
|
if [[ $http_status_code -eq 200 ]]; then
|
||||||
|
|
||||||
response=$(cat "$response_file")
|
response=$(cat "$response_file")
|
||||||
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)
|
current_time=$(date +%s)
|
||||||
time_difference=$((current_time - latest_block_timestamp_decimal))
|
time_difference=$((current_time - latest_block_timestamp_decimal))
|
||||||
|
|
||||||
if [ $time_difference -lt 60 ]; then
|
rm "$response_file"
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
echo "do a quick fitness test"
|
# echo "do a quick fitness test"
|
||||||
# use the proxy to normalize responses from different implementations of eth endpoints.
|
# use the proxy to normalize responses from different implementations of eth endpoints.
|
||||||
# make the proxy exit on a mismatch
|
# make the proxy exit on a mismatch
|
||||||
# push a few seconds of ethspam | versus through the proxy to give it a chance to hit a mismatch
|
# push a few seconds of ethspam | versus through the proxy to give it a chance to hit a mismatch
|
||||||
@@ -45,9 +47,34 @@ for path in $pathlist; do
|
|||||||
response2=$(cat "$response_file2")
|
response2=$(cat "$response_file2")
|
||||||
latest_block_hash2=$(echo "$response2" | jq -r '.result.hash')
|
latest_block_hash2=$(echo "$response2" | jq -r '.result.hash')
|
||||||
|
|
||||||
if [ "$latest_block_hash" == "$latest_block_hash22" ]; then
|
rm "$response_file2"
|
||||||
|
|
||||||
|
if [ "$latest_block_hash" == "$latest_block_hash2" ]; then
|
||||||
|
response_file3=$(mktemp)
|
||||||
|
|
||||||
|
http_status_code=$(curl --ipv4 -m 1 -s -X POST -w "%{http_code}" -o "$response_file" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' $RPC_URL)
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
if [[ $http_status_code -eq 200 ]]; then
|
||||||
|
response3=$(cat "$response_file3")
|
||||||
|
latest_block_timestamp3=$(echo "$response" | jq -r '.result.timestamp')
|
||||||
|
latest_block_timestamp_decimal3=$((16#${latest_block_timestamp3#0x}))
|
||||||
|
time_difference3=$(( latest_block_timestamp_decimal3 - latest_block_timestamp_decimal ))
|
||||||
|
|
||||||
|
rm "$response_file3"
|
||||||
|
|
||||||
|
if [ $time_difference3 -lt 2 ]; then
|
||||||
echo "online"
|
echo "online"
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [ $time_difference3 -lt 5 ]; then
|
||||||
|
echo "lagging"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "syncing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "forked"
|
echo "forked"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -55,13 +82,14 @@ for path in $pathlist; do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "$response_file2"
|
|
||||||
echo "unverified"
|
echo "unverified"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
elif [ $time_difference -lt 60 ]; then
|
||||||
|
|
||||||
echo "online"
|
echo "online"
|
||||||
exit 0
|
exit 0
|
||||||
|
else
|
||||||
|
echo "behind"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [[ $http_status_code -eq 404 ]]; then
|
elif [[ $http_status_code -eq 404 ]]; then
|
||||||
echo "offline"
|
echo "offline"
|
||||||
@@ -81,7 +109,6 @@ for path in $pathlist; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "$response_file"
|
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "not found"
|
echo "not found"
|
||||||
|
|||||||
Reference in New Issue
Block a user