-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindSplit.sh
More file actions
executable file
·60 lines (44 loc) · 1.3 KB
/
FindSplit.sh
File metadata and controls
executable file
·60 lines (44 loc) · 1.3 KB
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
#!/bin/bash
#!/bin/bash
min() {
printf "%s\n" "${@:2}" | sort "$1" | head -n1
}
CLIOK="/usr/local/bin/beetlecoin-cli -conf=${HOME}/.beetlecoin${1}/beetlecoin.conf"
CLIOK_GETBLOCKHASH="${CLIOK} getblockhash"
CLIOK_GETBLOCKCOUNT="${CLIOK} getblockcount"
CLIKO="/usr/local/bin/beetlecoin-cli -conf=${HOME}/.beetlecoin${2}/beetlecoin.conf"
CLIKO_GETBLOCKHASH="${CLIKO} getblockhash"
CLIKO_GETBLOCKCOUNT="${CLIKO} getblockcount"
CLIOK_COUNT=$( $CLIOK_GETBLOCKCOUNT )
CLIKO_COUNT=$( $CLIKO_GETBLOCKCOUNT )
START_BLOCK=$( min -g $CLIOK_COUNT $CLIKO_COUNT )
BLOCK=$START_BLOCK
END_BLOCK=1
#echo "CLIOK Count = ${CLIOK_COUNT}"
#echo "CLIKO Count = ${CLIKO_COUNT}"
#echo "Start Block = ${START_BLOCK}"
#echo ""
SPLITTED=0
while [ $BLOCK -gt $END_BLOCK ]
do
CLIOK_HASH=$( ${CLIOK_GETBLOCKHASH} ${BLOCK} )
CLIKO_HASH=$( ${CLIKO_GETBLOCKHASH} ${BLOCK} )
echo "#${BLOCK} ${CLIOK_HASH} ${CLIKO_HASH}"
if [ $CLIOK_HASH == $CLIKO_HASH ]
then
break
fi
SPLITTED=1
((BLOCK--))
done
echo ""
if [ $SPLITTED == 1 ]
then
BAD_BLOCK=$(($BLOCK + 1))
BAD_HASH=$( ${CLIKO_GETBLOCKHASH} ${BAD_BLOCK} )
echo "SPLIT CHAIN FOUND AT BLOCK # ${BAD_BLOCK} = ${BAD_HASH}"
exit 1
else
echo "No split chain found"
exit 0
fi