-
Notifications
You must be signed in to change notification settings - Fork 288
/
verify_header.sh
executable file
·76 lines (70 loc) · 1.5 KB
/
verify_header.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
function download() {
net=$1
name=$2
if [ -f "$name" ]; then
echo -e "$net $name exists. use it"
return 0
fi
compress_name=$name.tar.gz
url=https://s3.ap-northeast-1.amazonaws.com/main1.starcoin.org/$net/$compress_name
for ((i = 0; i < 3; i++)); do
rm -f "$compress_name"
wget $url
case_status=$?
if [ $case_status -eq 0 ]; then
echo -e "download $net $name succ"
break
fi
done
case_status=$?
if [ $case_status -ne 0 ]; then
return $case_status
fi
tar xzvf "$compress_name"
case_status=$?
if [ $case_status -ne 0 ]; then
echo -e "tar $net $compress_name fail"
return $case_status
fi
return 0
}
function usage() {
echo -e "usage: verify_header.sh net"
echo -e "net is main, barnard, proxima, halley"
}
function verify_header() {
net=$1
block_list=$2
download "$net" "$block_list"
while read line; do
name=$line
download "$net" "$name"
case_status=$?
if [ $case_status -ne 0 ]; then
echo -e "download $net $name fail"
exit $case_status
fi
./starcoin_db_exporter verify-header -i "$name" --batch-size 16
case_status=$?
if [ $case_status -ne 0 ]; then
echo -e "verify-header $net $name fail"
exit $case_status
fi
done <"$block_list"
echo -e "$net verify-header succ"
}
if [ $# != 1 ]; then
usage
exit 1
fi
net=$1
case $net in
"main" | "barnard" | "proxima" |"halley")
verify_header "$net" block_list.csv
;;
*)
echo "$net not supported"
usage
;;
esac