From 36339e1f2839305e22748b9d3cf347847592565a Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 1 Feb 2023 06:51:02 +0200 Subject: Removed -z flag and functionality, add regex check for IPFS CIDv0 --- bin/enter | 62 +++++--------------------------------------------------------- 1 file changed, 5 insertions(+), 57 deletions(-) (limited to 'bin/enter') diff --git a/bin/enter b/bin/enter index a4aa2ef..584d0e0 100755 --- a/bin/enter +++ b/bin/enter @@ -28,7 +28,6 @@ usage(){ echo "Usage:" echo " --help, -h Print this help and exit" echo " --chain , -n Crawl specified chain" - echo " --show-zblocks-only, -z Show only zblocks" echo " --no-verify, -nV Don't verify signatures" echo " Specify IPFS CID for entrance" echo "" @@ -52,65 +51,14 @@ then elif [ ! -z "$1" ] && [ "$1" == "-n" ] then entrance="$(ipns-resolve $2)" -elif [ ! -z "$1" ] && [ "$1" == "--show-zblocks-only" ] || [ "$1" == "-z" ] +elif [ ! -z "$1" ] then - # Enter temp folder - TEMPASSIN="/tmp/aktmp_$(date -u +%s)" - mkdir $TEMPASSIN - cd $TEMPASSIN - ccounter=0 - entrance="$(cat $ZLATEST)" - seed="$(cat $ZGENESIS)" - echo -n '[' - zblock=$entrance - while true - do - if [ "$counter" == 0 ] - then - echo -n "[" - fi - counter=$(expr $counter + 1) - if [ ! -v $zblock ] - then - if [ "$zblock" != "$seed" ] - then - timestamp='' - echo -n '{"zblock":"'$zblock'",' - ipfs --timeout=10s cat $zblock | json2bash > $TEMPASSIN/tmp-zblock - source $TEMPASSIN/tmp-zblock - ipfs --timeout=10s cat $block | json2bash > $TEMPASSIN/tmp-block - source $TEMPASSIN/tmp-block - logit "[INFO]" "BLOCK REFERENCED" - if [ ! -v $timestamp ] - then - echo -n '"timestamp":"'$timestamp'",' - fi - echo -n '"block_signature":"'$block_signature'",' - echo -n '"gpg":"'$gpg'",' - - if [ -v $previous ] - then - logit "[ERROR]" "Block $block has no previous zblock $previous. Appending default genesis to close cleanly." - echo -n '"previous":"genesis"},{"genesis":"genesis"}]' - exit 0 - else - echo -n '"previous":"'$previous'"},' - zblock=$previous - fi - elif [ "$zblock" == "$seed" ] - then - echo -n '{"genesis":"genesis"}]' - logit "[INFO]" "Counter $counter" - exit 0 - fi - else - echo "Check not passed... No previous IPFS CID" + echo $1 | grep -e 'Qm.\{44\}' >/dev/null + if [ "$?" -ne 0 ] + then + logit "[ERROR]" "Argument provided was not an IPFS CIDv0 string" exit 1 fi -done - -elif [ ! -z "$1" ] -then entrance="$1" else # By default we enter from the latest block -- cgit v1.2.3