aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-zblock-show
blob: 3244c4b3ac7d404ca5e075d2d1d71836ce5d3229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# ak-zblock-show
# ak-zblock [IPFS CID]
#
# Returns a JSON array representing the chain retrieved.
# Logs messages to $LOGSFILE.

PROGRAM="$(basename $0)"

logit(){
    ak-logthis "<$PROGRAM>" "$1" "$2"
}

usage(){
    echo "$PROGRAM - Show a zblock"
    echo ""
    echo "$PROGRAM <zblock_hash>"
    echo "Usage:"
    echo "    --help, -h        Print this help and exit"
}
verify=1
if [ ! -z "$1" ] && [ "$1" == "-h" ] || [ "$1" == "--help" ]
then
    usage
    exit
elif [ ! -z "$1" ]
then
    echo $1 | grep -e 'Qm.\{44\}' >/dev/null
    if [ "$?" -ne 0 ]
    then
        logit "[ERROR]" "Argument provided ($1) was not an IPFS CIDv0 string"
        exit 1
    fi
    entrance="$1"
else
    entrance="$(cat $AK_ZLATEST)"
fi
ak-enter -l 1 "$entrance" > "$AK_CACHEDIR/fzblocks/$entrance"