forked from AleoNet/snarkOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-prover.sh
executable file
·73 lines (57 loc) · 1.48 KB
/
run-prover.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
#!/bin/bash
# USAGE examples:
# CLI with env vars: MINER_ADDRESS=aleoABCD... OPERATOR_IP_ADDRESS=a.b.c.d ./run-prover.sh
# CLI with prompts for vars: ./run-prover.sh
# if env var MINER_ADDRESS is not set, prompt for it
if [ -z "${MINER_ADDRESS}" ]
then
read -r -p "Enter your miner address: "
MINER_ADDRESS=$REPLY
fi
if [ "${MINER_ADDRESS}" == "" ]
then
MINER_ADDRESS="aleo1d5hg2z3ma00382pngntdp68e74zv54jdxy249qhaujhks9c72yrs33ddah"
fi
# if env var OPERATOR_IP_ADDRESS is not set, prompt for it
if [ -z "${OPERATOR_IP_ADDRESS}" ]
then
read -r -p "Enter your Operator Servers IP address: "
OPERATOR_IP_ADDRESS=$REPLY
fi
if [ "${OPERATOR_IP_ADDRESS}" == "" ]
then
echo "IP Address of Operator server is required to run a prover"
exit 1
fi
# if env var OPERATOR_IP_ADDRESS is not set, use default port of 4132
if [ -z "${OPERATOR_IP_PORT}" ]
then
OPERATOR_IP_PORT=4132
fi
COMMAND="cargo run --release -- --prover ${MINER_ADDRESS} --pool ${OPERATOR_IP_ADDRESS}:${OPERATOR_IP_PORT} --trial --verbosity 2"
for word in $*;
do
COMMAND="${COMMAND} ${word}"
done
function exit_node()
{
echo "Exiting..."
kill $!
exit
}
trap exit_node SIGINT
echo "Running prover node..."
$COMMAND &
while :
do
echo "Checking for updates..."
git stash
rm Cargo.lock
STATUS=$(git pull)
if [ "${STATUS}" != "Already up to date." ]; then
echo "Updated code found, rebuilding and relaunching miner"
cargo clean
kill -INT $!; sleep 2; $COMMAND &
fi
sleep 1800;
done