-
Notifications
You must be signed in to change notification settings - Fork 8
/
forktargetsq
70 lines (65 loc) · 3.7 KB
/
forktargetsq
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
#! /usr/bin/env bash
function print_usage () {
echo "forktargets help:"
echo
echo "SYNOPSIS: Lists the target wallet addresses as configured in every active fork farmer's config.yaml"
echo " in a single organized list for easier visual comparison to whatever list the user is maintaining"
echo " of wallet receive addresses they intend their farmed rewards to go to."
echo " Also compares the target setting in config.yaml to the RPC call for the same value, and"
echo " prints an urgent warning if they don't match."
echo
echo "PARAMETERS:"
echo " -help | --help Show this information again."
echo
exit 0
}
. ftinit.sh
. ftbuildrunlists.sh
OLDIFS=$IFS
for fork in $FARMERLIST; do
CURRENTCONFIG=$FORKTOOLSHIDDENDIRS/.$fork/mainnet/config/config.yaml
if [[ ! -f $CURRENTCONFIG ]]; then
continue
fi
# CD and activate venv
cd $FORKTOOLSBLOCKCHAINDIRS/$fork-blockchain
. ./activate
# This is a pared down version of ftparseports.sh that just grabs FARMERRPCPORT and config target address, because that's all we need here
# Mainly splitting this out because people might get nervous if I have it checking for config target address in forktools that have no clear use for it
# Best to keep that out of the general port parsing include
IFS=''
MEMORYCONFIG=$(cat $CURRENTCONFIG | c1grep -e '^harvester:' -e '^farmer:' -e '^full_node:' -e '^timelord:' -e '^timelord_launcher:' -e '^ui:' -e '^introducer:' -e '^wallet:' -e '^logging:' -e 'port: ' -e '_peer:' -e 'vdf_server:' -e 'target_address:')
while read line; do
WORKLINE=$(sed 's/#.*//' <<< "$line" ) # This removes any comments from consideration for alteration
TESTSECTION=$(c1grep -e '^harvester:' -e '^farmer:' -e '^full_node:' -e '^timelord:' -e '^timelord_launcher:' -e '^ui:' -e '^introducer:' -e '^wallet:' -e '^pool:' -e '^logging:' <<< "$WORKLINE" )
if [[ $TESTSECTION != '' && $TESTSECTION != $SECTION ]]; then
SECTION=$TESTSECTION
continue
fi
if [[ $SECTION == *farmer:* && $WORKLINE == *rpc_port:* ]]; then
FARMERRPCPORT=$(sed 's/rpc_port: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
if [[ $SECTION = *farmer:* && $WORKLINE == *target_address:* ]]; then
CONFIGTARGETADDRESS=$(sed 's/.*target_address: //' <<< "$WORKLINE" | awk '{$1=$1};1')
continue
fi
done < <(printf '%s\n' "$MEMORYCONFIG")
FORKNAME=$fork
RPCTARGETADDRESS=$(curl -s --insecure --cert $FORKTOOLSHIDDENDIRS/.$FORKNAME/mainnet/config/ssl/farmer/private_farmer.crt --key $FORKTOOLSHIDDENDIRS/.$FORKNAME/mainnet/config/ssl/farmer/private_farmer.key -d '{"search_for_private_key":false}' -H "Content-Type: application/json" -X POST https://localhost:$FARMERRPCPORT/get_reward_targets | python -m json.tool )
RPCTARGETADDRESS=$(echo $RPCTARGETADDRESS | grep "farmer_target" | sed 's/.*"farmer_target": "//' | sed 's/".*//' | awk '{$1=$1};1')
if [[ $CONFIGTARGETADDRESS == $RPCTARGETADDRESS ]]; then
printf "%16.16s - config.yaml and Farmer RPC agree. Address: %25s\n" "$fork" "$CONFIGTARGETADDRESS"
else
RED='\033[1;31m'
NC='\033[0m' # No Color
printf "%16.16s - ${RED}WARNING! config.yaml and RPC target addresses DO NOT MATCH! WARNING!${NC}\n" "$fork"
echo " When this happens, rewards actually go to the RPC target address."
echo " If you recently edited the config.yaml but didn't restart your farmer, you should restart it or revert your config changes."
echo " config.yaml: $CONFIGTARGETADDRESS"
echo " Farmer RPC call: $RPCTARGETADDRESS"
fi
deactivate
done
echo
IFS=$OLDIFS