From 07587e99d6f7e5027dc8b946ad84c38d4e91e00d Mon Sep 17 00:00:00 2001 From: goldsquid Date: Thu, 4 Sep 2025 20:35:07 +0700 Subject: [PATCH] latest --- latest.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/latest.sh b/latest.sh index a70e992e..7010d821 100755 --- a/latest.sh +++ b/latest.sh @@ -16,6 +16,8 @@ if [ -n "$NO_SSL" ]; then DOMAIN="${DOMAIN:-0.0.0.0}" fi +blocktag=${2:-latest} + pathlist=$(cat $BASEPATH/$1.yml | grep -oP "stripprefix\.prefixes.*?/\K[^\"]+") for path in $pathlist; do @@ -29,13 +31,13 @@ for path in $pathlist; do if $include; then RPC_URL="${PROTO:-https}://$DOMAIN/$path" - if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":1}' | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}'; then + if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["${blocktag}",false],"id":1}' | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}'; then exit 0 else - if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":1}' | jq; then + if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["${blocktag}",false],"id":1}' | jq; then exit 1 else - curl -L -vv -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":1}' + curl -L -vv -X POST $RPC_URL -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["${blocktag}",false],"id":1}' fi fi fi