From 5b9d80959bdfab7fedb7a307d324811ba49b6aa5 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sat, 8 Mar 2025 17:08:37 +0200 Subject: Keeping history of published ZBLOCKs outside IPFS --- lib/_ak_zblock | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/_ak_zblock') diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 667bf80..9d38711 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -615,6 +615,8 @@ function _ak_zblock_repack(){ # Optional or extending with # python send_as_ak_tx $ZBLOCK # or for "offline" use + archivaltime="$(date -u +%s)" + echo "${archivaltime} $(cat $AK_ZLATEST)" >> $AK_ZLATEST_HISTORY echo $ZBLOCK > $AK_ZLATEST _ak_ipfs_name_publish zchain /ipfs/$ZBLOCK #> /dev/null 2>&1 if [ $? -ne 0 ] @@ -633,7 +635,7 @@ function _ak_zblock_repack(){ exit 1 fi fi - _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1) > /dev/null 2>&1 + _ak_ipfs_files_cp /zlatest /zarchive/${archivaltime}-$(_ak_ipfs_files_stat /zlatest | head -n 1) > /dev/null 2>&1 if [ $? -ne 0 ] then _ak_log_error "Could not back up previous /zlatest" @@ -691,7 +693,7 @@ function _ak_zblock_pack(){ _ak_gpg_key_self_export $KEY GPG_PUB_KEY=$(_ak_ipfs_add $KEY) # Acquire last block of information, to chain this one with previous posted - PREVIOUS=$(_ak_ipfs_files_stat /zlatest | head -n 1) + PREVIOUS="$(cat $AK_ZLATEST)" # We create a block of json like this: printf '{"timestamp":"%s","action":"%s","data":"%s","detach":"%s","gpg":"%s","previous":"%s"}' $(date -u +%s) $ACTION $MESSAGE_HASH $MESSAGE_SIGNATURE $GPG_PUB_KEY $PREVIOUS > block BLOCK="block" @@ -716,6 +718,8 @@ function _ak_zblock_pack(){ # Optional or extending with # python send_as_ak_tx $ZBLOCK # or for "offline" use + archivaltime="$(date -u +%s)" + echo "${archivaltime} $(cat $AK_ZLATEST)" >> $AK_ZLATEST_HISTORY echo $ZBLOCK > $AK_ZLATEST _ak_ipfs_name_publish zchain /ipfs/$ZBLOCK > /dev/null 2>&1 if [ $? -ne 0 ] @@ -734,7 +738,7 @@ function _ak_zblock_pack(){ exit 1 fi fi - _ak_ipfs_files_cp /zlatest /zarchive/$(date -u +%s)-$(_ak_ipfs_files_stat /zlatest | head -n 1) > /dev/null 2>&1 + _ak_ipfs_files_cp /zlatest /zarchive/${archivaltime}-$(_ak_ipfs_files_stat /zlatest | head -n 1) > /dev/null 2>&1 if [ $? -ne 0 ] then _ak_log_error "Could not back up previous /zlatest" -- cgit v1.2.3