From 003bcc7e7bd64ab3fc30a9643478f9f1bae84fee Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Fri, 21 Mar 2025 06:32:25 +0100 Subject: [PATCH] speedup with less errors --- show-status.sh | 12 +++++++----- sync-status.sh | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/show-status.sh b/show-status.sh index ccd8d6a8..929e3a5f 100755 --- a/show-status.sh +++ b/show-status.sh @@ -17,21 +17,23 @@ check_sync_status() { local part=$1 result=$("$BASEPATH/sync-status.sh" "${part%.yml}") + code=0 + if [ $? -ne 0 ]; then if [[ "$result" == *"syncing"* ]]; then # Allow exit status 1 if result contains "syncing" - return 0 + code=0 elif [[ "$result" == *"lagging"* ]]; then # Allow exit status 1 if result contains "lagging" - return 0 + code=0 else any_failure=true - return 1 + code=1 fi fi echo "${part%.yml}: $result" - return 0 + return "$code" } @@ -71,4 +73,4 @@ done # If any invocation failed, return a failure exit code if $any_failure; then exit 1 -fii +fi diff --git a/sync-status.sh b/sync-status.sh index 74424b63..c1b17179 100755 --- a/sync-status.sh +++ b/sync-status.sh @@ -33,9 +33,24 @@ for path in $pathlist; do if [ -n "$2" ]; then ref="$2" else - chain_id=$(curl --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $RPC_URL | jq -r '.result') - chain_id_decimal=$((16#${chain_id#0x})) - ref=$($BASEPATH/reference-rpc-endpoint.sh $chain_id_decimal) + chain_id_response=$(curl --ipv4 -m 1 -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' $RPC_URL) + + if [ $? -eq 0 ]; then + chain_id=$(echo "$chain_id_response" | jq -r '.result' 2>/dev/null) + + # echo "$RPC_URL: $chain_id" + + if [[ "$chain_id" =~ ^0x[0-9a-fA-F]+$ ]]; then + chain_id_decimal=$((16#${chain_id#0x})) + ref=$($BASEPATH/reference-rpc-endpoint.sh $chain_id_decimal) + else + echo "error" + exit 1 + fi + else + echo "error" + exit 1 + fi fi # Call the health check script with RPC_URL and ref @@ -44,5 +59,5 @@ for path in $pathlist; do fi done -echo "not found" +echo "unverified" exit 1