-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcheckmasks
More file actions
executable file
·48 lines (41 loc) · 2.8 KB
/
checkmasks
File metadata and controls
executable file
·48 lines (41 loc) · 2.8 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
#!/bin/bash
#
# Running with no parameter will give a summary
# ./checkmasks all - will output detail for each node
# ./checkmasks <maskhex> - will output detail for a specific mask
#
# @author webworker01
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
if [[ ! -z $1 ]]; then
if [[ "$1" == "all" ]]; then
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\"}" | jq -c -r .[]
else
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$1\"}" | jq -c -r .
fi
else
mynotaryid=$(komodo-cli getinfo | jq .notaryid)
bestmaskdata=$(curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\"}")
seedrecvmask=$(echo $bestmaskdata | jq --arg seedid $referencenode '.[$seedid|tonumber] | .recvmask' | sed 's/"//g' | awk '{$1=$1};1')
echo "Seed recvmask: $seedrecvmask"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$seedrecvmask\"}" | jq -c -r '. | del(.maskhex) | del(.tag) | .set'
echo "not:"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$seedrecvmask\"}" | jq -c -r '. | del(.maskhex) | del(.tag) | .not'
myrecvmask=$(echo $bestmaskdata | jq --arg nodeid $mynotaryid '.[$nodeid|tonumber].recvmask' | sed 's/"//g' | awk '{$1=$1};1')
echo
echo "My recvmask: $myrecvmask"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$myrecvmask\"}" | jq -c -r '.set'
echo "not:"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$myrecvmask\"}" | jq -c -r '. | del(.maskhex) | del(.tag) | .not'
bestmask=$(echo $bestmaskdata | jq -c 'group_by(.bestmask) | del(.[] | select(.[0].bestmask == " 0" )) | del(.[] | select(.[0].bestmask == " 0" )) | map ({ "total":length, "bestmask":.[0].bestmask }) | sort_by(.total) | reverse')
bestmaskmask=$(echo $bestmask | jq .[0].bestmask | sed 's/"//g' | awk '{$1=$1};1')
bestmaskcount=$(echo $bestmask | jq .[0].total | sed 's/"//g')
echo
echo "Best bestmask: $bestmaskmask [$bestmaskcount agree]"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$bestmaskmask\"}" | jq -c -r '.set'
mybestmask=$(echo $bestmaskdata | jq --arg nodeid $mynotaryid '.[$nodeid|tonumber].bestmask' | sed 's/"//g' | awk '{$1=$1};1')
echo
echo "My bestmask: $mybestmask"
curl -s --url "http://127.0.0.1:${iguanaport}" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"$mybestmask\"}" | jq -c -r '.set'
fi