-
Notifications
You must be signed in to change notification settings - Fork 5
/
windistrib
executable file
·90 lines (78 loc) · 1.8 KB
/
windistrib
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
## Description: Show (or graph) eligible plot distribution per Proof Check, by occurrence.
# Manually set this, and uncomment if you want to display plot count
#COUNT=false
#CHIAPATH="$HOME/path/to/chia-blockchain"
#if [[ $COUNT == true ]] && [[ ! -z $CHIAPATH ]]; then
# source $CHIAPATH/activate
# PLOTCOUNT=$(chia farm summary | grep 'plots of size' | grep -o '[^$(printf '\t') ].*')
#fi
LOGPATH="$HOME/.chia/mainnet/log/debug.log*"
if [[ ! $(ls -A $LOGPATH) ]]; then
echo "No files found at $LOGPATH"
echo "Update line 3 of $0 and try again"
exit 1
fi
## Functions
usage() {
echo "Usage: $0 [OPTION]" 1>&2
exit 1
}
plottery() {
stdbuf -o0 grep -s 'eligible' \
<(stdbuf -o0 cat $LOGPATH) | \
awk -F" " '{print " ", $5"\t", "┃ ", $13}'
}
showdistrib() {
cat <<-'EOF'
E: Eligible plots
O: Occurrence
E: O:
━━━━╋━━━━
EOF
plottery | \
awk '{print $1}' | \
tail +4 | \
sort -n | \
uniq -c | \
sort -n | \
awk '{print " "$2"•", $1}' | \
column -s'•' -t
if [[ $COUNT == true ]]; then
echo -e "\nWith: $PLOTCOUNT"
fi
}
wingraph() {
if ! [ -x "$(command -v uplot)" ]; then
echo 'Error: uplot is not installed, or installed gem is not added to PATH' >&2
echo 'Get it at: https://github.com/red-data-tools/YouPlot' >&2
echo 'Get it with: gem install youplot' >&2
exit 1
fi
echo ""
plottery | \
uplot c -r \
-t "(E)ligible plots per Proof Check, by (O)ccurrence" \
-x "O" \
-y "E " \
-b barplot
if [[ $COUNT == true ]]; then
echo -e "\nWith: $PLOTCOUNT"
fi
}
## End Functions
while getopts "g" opt; do
case "$opt" in
g)
GRAPH=true
;;
*)
usage
;;
esac
done
if [[ $GRAPH == true ]]; then
wingraph
else
showdistrib
fi