aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-17 09:25:24 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-17 09:25:24 +0300
commitcdf6fdb9d0d864e38ff31a3b06402e5c7dd1090d (patch)
treea3aa446634644cade45fb2052c2298b1663108c4
parent7b3a9fbef2c28a6ea7c2b5a49f8a130f4d1bf05f (diff)
downloadarching-kaos-tools-cdf6fdb9d0d864e38ff31a3b06402e5c7dd1090d.tar.gz
arching-kaos-tools-cdf6fdb9d0d864e38ff31a3b06402e5c7dd1090d.tar.bz2
arching-kaos-tools-cdf6fdb9d0d864e38ff31a3b06402e5c7dd1090d.zip
removing ak-find-latest-mined-sblock
-rw-r--r--README1
-rwxr-xr-xapi/make_cache.sh2
-rwxr-xr-xapi/tests/latest_known_mined_block.sh2
-rwxr-xr-xbin/ak-find-latest-mined-sblock95
-rwxr-xr-xbin/ak-miner-script2
-rwxr-xr-xlib/_ak_schain6
6 files changed, 6 insertions, 102 deletions
diff --git a/README b/README
index b105b7a..5b6306a 100644
--- a/README
+++ b/README
@@ -275,7 +275,6 @@ Experimental
- ak-mempool # TODO
- ak-miner-script PROTO Prototype miner
- ak-get-balances # Returns a balances from SCHAIN
- - ak-find-latest-mined-sblock # In a hay of SBLOCKS finds the latest
Modules
-------
diff --git a/api/make_cache.sh b/api/make_cache.sh
index e5f9bfc..c075f27 100755
--- a/api/make_cache.sh
+++ b/api/make_cache.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-ak-find-latest-mined-sblock > $AK_CACHEDIR/ak-find-latest-mined-sblock.json
+ak schain --get-latest > $AK_CACHEDIR/ak-find-latest-mined-sblock.json
ak zchain --crawl > $AK_CACHEDIR/ak-get-chain-minified.json
ak zchain --get-latest > $AK_CACHEDIR/ak-get-zlatest.json
diff --git a/api/tests/latest_known_mined_block.sh b/api/tests/latest_known_mined_block.sh
index c4e40bb..64ff612 100755
--- a/api/tests/latest_known_mined_block.sh
+++ b/api/tests/latest_known_mined_block.sh
@@ -5,7 +5,7 @@ printf '[%s]\n' "$PROGRAM"
printf "TEST\t/slatest\n"
printf "\t01:\tendpoint"
A="$(curl http://127.0.0.1:8610/v0/slatest 2>/dev/null)"
-B="$(ak-find-latest-mined-sblock)"
+B="$(ak schain --get-latest)"
if [ "$A" == "$B" ]
then
printf '\t\t\033[0;32mPASSED\033[0;0m'
diff --git a/bin/ak-find-latest-mined-sblock b/bin/ak-find-latest-mined-sblock
deleted file mode 100755
index dda1196..0000000
--- a/bin/ak-find-latest-mined-sblock
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/bash
-cd $AK_MINEDBLOCKSDIR
-PROGRAM="$(basename $0)"
-declare -A counters
-source $AK_LIBDIR/_ak_log
-source $AK_LIBDIR/_ak_script
-source $AK_LIBDIR/_ak_ipfs
-
-if [ ! -z $1 ] && [ -n "$1" ]
-then
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]
- then
- echo "$PROGRAM - Finds longest schain from the $AK_MINEDBLOCKSDIR dir">&2
- exit 2
- fi
-fi
-
-further(){
- # _ak_log_info "Diving into $1"
- lookfor $1
-}
-
-lookfor(){
- echo -n $1 | grep -e '[0-9a-f]\{128\}' > /dev/null
- if [ $? -ne 0 ]
- then
- _ak_log_error "Oops!!! The argument passed, does not match the regular expression!"
- else
- counters[$CHAIN_PARENT]="$(expr ${counters[$CHAIN_PARENT]} + 1)"
- if [ $? -ne 0 ]
- then
- echo "$1, $counters[$1]"
- exit 1
- fi
- _ak_log_info "Accessing file: $1"
- # echo "$1 file:"
- # cat "$1" | jq
- NEXT_TARGET="$(cat "$1" | jq | grep previous | tr -d ' ' | sed -e 's/previous//g; s/[",:]//g;')"
- if [ -n "$NEXT_TARGET" ]
- then
- _ak_log_info "Found previous: $NEXT_TARGET"
- if [ ! -f "$NEXT_TARGET" ]
- then
- _ak_log_warning "Could not find $NEXT_TARGET"
- else
- further "$NEXT_TARGET"
- fi
- else
- _ak_log_warning "No next target found. So long for $1"
- fi
- fi
-}
-
-_ak_sblock_get_latest_from_haystack_of_sblocks(){
- templistblock="$(_ak_make_temp_file)"
- find $AK_MINEDBLOCKSDIR -maxdepth 1 -type f | while read line
- do
- basename "${line}" >> $templistblock
- done
- if [ "$(cat $templistblock | wc -l)" -ne 0 ]
- then
- while IFS="" read -r p || [ -n "$p" ]
- do
- # if [ ! "$p" = "" ] && [ ! "$p" = "tmplistblock" ]
- if [ "$(echo $p | tr -d '\n' | wc -c)" = 128 ]
- then
- filename="$(basename $p)"
- _ak_log_info "Investigating $filename..."
- export CHAIN_PARENT="$filename"
- counters[$CHAIN_PARENT]=1
- lookfor "$filename"
- else
- _ak_log_warning "Nothing to do with $filename"
- fi
- done < $templistblock
- rm $templistblock
- max=0
- max_holder=0
- for value in "${!counters[@]}"
- do
- # echo "${value} : ${counters[${value}]}"
- if [ ${counters[${value}]} -gt $max ]
- then
- max="${counters[${value}]}"
- max_holder="${value}"
- _ak_log_info "New MAX $max on $max_holder"
- fi
- done
- else
- max_holder="00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
- fi
- echo -n '{"latest_block":"'$max_holder'"}' | tee $AK_WORKDIR/schain.latest
-}
-
-_ak_sblock_get_latest_from_haystack_of_sblocks $1
diff --git a/bin/ak-miner-script b/bin/ak-miner-script
index 9843ac6..bf0eef7 100755
--- a/bin/ak-miner-script
+++ b/bin/ak-miner-script
@@ -20,7 +20,7 @@ gather_zblocks(){
proofofwork(){
TEST="$(gather_zblocks)"
MINER="$(ak-gpg --get-key-self-as-ipfs)"
- PRE="$(ak-find-latest-mined-sblock | jq -r '.latest_block' | tr -d $'\n')"
+ PRE="$(ak schain --get-latest | jq -r '.latest_block' | tr -d $'\n')"
i=1
l=1; while [ $l = 1 ]
do
diff --git a/lib/_ak_schain b/lib/_ak_schain
index 987ee83..809a454 100755
--- a/lib/_ak_schain
+++ b/lib/_ak_schain
@@ -8,13 +8,13 @@ GENESIS="00000000000000000000000000000000000000000000000000000000000000000000000
_ak_schain_latest_cached(){
if [ ! -f $AK_WORKDIR/schain.latest ]
then
- ak-find-latest-mined-sblock > $AK_WORKDIR/schain.latest
+ _ak_schain_get_latest > $AK_WORKDIR/schain.latest
fi
cat $AK_WORKDIR/schain.latest
}
_ak_schain_tidy(){
- SLATEST=$(ak-find-latest-mined-sblock | jq -r '.latest_block')
+ SLATEST=$(_ak_schain_get_latest | jq -r '.latest_block')
if [ ! -d $AK_SCHAINSDIR ]
then
mkdir $AK_SCHAINSDIR
@@ -22,7 +22,7 @@ _ak_schain_tidy(){
}
_ak_schain_block_latest_block_hash(){
- ak-find-latest-mined-sblock | jq -r '.latest_block'
+ _ak_schain_get_latest | jq -r '.latest_block'
}
_ak_schain_crawl(){