aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-02-28 07:09:00 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-02-28 07:09:00 +0200
commit9da29bce4fdd4ca0754f9c505b746d68182f6046 (patch)
tree0de34422eb0fd88ea47b51146667d85ba28dcc77
parent9c249804a4555793532b7ee3eb2d501c2f328cb9 (diff)
downloadarching-kaos-tools-9da29bce4fdd4ca0754f9c505b746d68182f6046.tar.gz
arching-kaos-tools-9da29bce4fdd4ca0754f9c505b746d68182f6046.tar.bz2
arching-kaos-tools-9da29bce4fdd4ca0754f9c505b746d68182f6046.zip
Refactoring
-rwxr-xr-xbin/ak-calculate-size14
-rwxr-xr-xbin/ak-cli4
-rwxr-xr-xbin/ak-extract-cids8
-rwxr-xr-xbin/ak-zchain-calculate-size29
-rwxr-xr-xbin/ak-zchain-extract-cids13
5 files changed, 44 insertions, 24 deletions
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