From 9da29bce4fdd4ca0754f9c505b746d68182f6046 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 28 Feb 2024 07:09:00 +0200 Subject: Refactoring --- bin/ak-calculate-size | 14 -------------- bin/ak-cli | 4 ++-- bin/ak-extract-cids | 8 -------- bin/ak-zchain-calculate-size | 29 +++++++++++++++++++++++++++++ bin/ak-zchain-extract-cids | 13 +++++++++++++ 5 files changed, 44 insertions(+), 24 deletions(-) delete mode 100755 bin/ak-calculate-size delete mode 100755 bin/ak-extract-cids create mode 100755 bin/ak-zchain-calculate-size create mode 100755 bin/ak-zchain-extract-cids (limited to 'bin') diff --git a/bin/ak-calculate-size b/bin/ak-calculate-size deleted file mode 100755 index 63ae2f7..0000000 --- a/bin/ak-calculate-size +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -ak-extract-cids > to_stats -sum=0 ; while IFS="" read -r p || [ -n "$p" ] -do - if [ "$p" != "" ] - then - num=$(ak-ipfs-block-stat $p | grep Size | sed -e 's/Size: //g') - else - num=0 - fi - sum=$(expr $sum + $num ) -done < to_stats -echo "Chain is : $sum bytes" -rm to_stats diff --git a/bin/ak-cli b/bin/ak-cli index 6923823..b54cfc3 100755 --- a/bin/ak-cli +++ b/bin/ak-cli @@ -333,7 +333,7 @@ help_network(){ help_utils(){ printf ' - ak-calculate-size + ak-zchain-calculate-size ' printf ' ak-data-expand @@ -357,7 +357,7 @@ help_uncatecorized(){ ak-get-chain-minified ' printf ' - ak-extract-cids + ak-zchain-extract-cids ' printf ' ak-get-ipfs-hashes-from-my-zchain diff --git a/bin/ak-extract-cids b/bin/ak-extract-cids deleted file mode 100755 index 3076ace..0000000 --- a/bin/ak-extract-cids +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# -# Extracts unique IPFS CIDs from an ak-entered zchain -# -# Previously: -# ak-enter | jq | grep Qm | sed -e 's/^.*Qm/Qm/g' | cut -d '"' -f 1 -# -ak-enter | jq | grep Qm | sed -e 's/".*"://g; s/ //g; s/[{,"]//g' | sort | uniq diff --git a/bin/ak-zchain-calculate-size b/bin/ak-zchain-calculate-size new file mode 100755 index 0000000..ca41e53 --- /dev/null +++ b/bin/ak-zchain-calculate-size @@ -0,0 +1,29 @@ +#!/bin/bash +PROGRAM="$(basename $0)" + +temp="$(mktemp -d)" + +cd $temp + +if [ ! -z $1 ] && [ -n "$1" ] +then + ak-extract-cids $1 > to_stats +else + ak-extract-cids > to_stats +fi + +sum=0 ; while IFS="" read -r p || [ -n "$p" ] +do + if [ "$p" != "" ] + then + ak-ipfs-get $p + num="$(du -bs --apparent-size $p | cut -d $'\t' -f 1)" + else + num=0 + fi + sum=$(expr $sum + $num ) +done < to_stats +echo "Chain is : $sum bytes" + +cd ~ +rm -rf $temp diff --git a/bin/ak-zchain-extract-cids b/bin/ak-zchain-extract-cids new file mode 100755 index 0000000..a07c481 --- /dev/null +++ b/bin/ak-zchain-extract-cids @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Extracts unique IPFS CIDs from an ak-entered zchain +# +# Previously: +# ak-enter | jq | grep Qm | sed -e 's/^.*Qm/Qm/g' | cut -d '"' -f 1 +# +if [ ! -z $1 ] && [ -n "$1" ] +then + ak-enter $1 | jq | grep Qm | sed -e 's/".*"://g; s/ //g; s/[{,"]//g' | sort | uniq +else + ak-enter | jq | grep Qm | sed -e 's/".*"://g; s/ //g; s/[{,"]//g' | sort | uniq +fi -- cgit v1.2.3