+}; # Print to stdout path of OTS file with oldest block
+get_block_num_from_stored_ots_path() {
+ # Desc: Return block number from stored OTS path
+ # Input: arg1 input file path
+ # Output: stdout block number (int)
+ # Note: Assumes OTS file name pattern '{digest}_{blockNum}.otsu'.
+ local fin fbase block re;
+ fpath="$1";
+ fbase="$(basename "$fpath")";
+ block="$(sed -E -e 's/^.+_([0-9]+).otsu$/\1/g' <<< "$fbase")";
+ re='[0-9]+';
+ if [[ "$block" =~ $re ]]; then
+ printf "%s" "$block";
+ else
+ yell "ERROR:Invalid block number:$(declare -p fpath fbase block)";
+ return 1;
+ fi;
+}; # Print block number from stored OTS file
+store_and_lookup() {
+ # Desc: Stores provided file's OTS files and retrieves older OTS files from storage if possible
+ # Usage: store_and_lookup [path]
+ # Depends: get_sha256_digest(), get_oldest_stored_ots_path(), get_ots_oldestblock()
+ local pathFileIn="$1";
+ vbm "DEBUG:Starting store_and_lookup() with provided file:${pathFileIn}";
+
+ # Validate path
+ if [[ ! -f "$pathFileIn" ]]; then yell "ERROR:Not a file:${pathFileIn}"; return 1; fi;