aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2022-05-18 17:50:51 +0300
committerkaotisk <kaotisk@arching-kaos.org>2022-05-18 17:50:51 +0300
commit1e965d6723ce0a9371d1166d29b246caf5ba8adf (patch)
treeff6f7627e4ea64d69f63fcb784537ead8862a61d
parent87f0e0a083bb7e1978cc03a92b304ff545701ebb (diff)
downloadarching-kaos-tools-origin/featureentershowzblocksonlyflag.tar.gz
arching-kaos-tools-origin/featureentershowzblocksonlyflag.tar.bz2
arching-kaos-tools-origin/featureentershowzblocksonlyflag.zip
Feature: Outputs your local's chain zblocks, with their signatures, timestamp, gpg public key and previous zblock. Iterates the whole chain and returns a JSON array of these entries sorted from latest to oldest.
-rwxr-xr-xbin/enter56
1 files changed, 56 insertions, 0 deletions
diff --git a/bin/enter b/bin/enter
index 625a020..0b74231 100755
--- a/bin/enter
+++ b/bin/enter
@@ -9,6 +9,62 @@
if [ ! -z "$1" ] && [ "$1" == "-n" ]
then
entrance="$(ipns-resolve $2)"
+elif [ ! -z "$1" ] && [ "$1" == "--show-zblocks-only" ]
+then
+ # Enter temp folder
+ TEMPASSIN="/tmp/aktmp_$(date -u +%s)"
+ mkdir $TEMPASSIN
+ cd $TEMPASSIN
+ ccounter=0
+ entrance="$(cat $ZLATEST)"
+ seed="$(cat $ZGENESIS)"
+ echo '['
+ zblock=$entrance
+ while true
+ do
+ if [ "$counter" == 0 ]
+ then
+ echo "["
+ fi
+ counter=$(expr $counter + 1)
+ if [ ! -v $zblock ]
+ then
+ if [ "$zblock" != "$seed" ]
+ then
+ timestamp=''
+ echo '{"zblock":"'$zblock'",'
+ ipfs cat $zblock | json2bash > $TEMPASSIN/tmp-zblock
+ source $TEMPASSIN/tmp-zblock
+ ipfs cat $block | json2bash > $TEMPASSIN/tmp-block
+ source $TEMPASSIN/tmp-block
+ logthis "BLOCK REFERENCED"
+ if [ ! -v $timestamp ]
+ then
+ echo '"timestamp":"'$timestamp'",'
+ fi
+ echo '"block_signature":"'$block_signature'",'
+ echo '"gpg":"'$gpg'",'
+
+ if [ -v $previous ]
+ then
+ echo "Block $block has no previous zblock"
+ exit 3
+ else
+ echo '"previous":"'$previous'"},'
+ zblock=$previous
+ fi
+ elif [ "$zblock" == "$seed" ]
+ then
+ echo '{"genesis":"genesis"}]'
+ logthis "Counter $counter"
+ exit 0
+ fi
+ else
+ echo "Check not passed... No previous IPFS CID"
+ exit 1
+ fi
+done
+
elif [ ! -z "$1" ]
then
entrance="$1"