-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathminerfixer
More file actions
executable file
·65 lines (56 loc) · 2.43 KB
/
minerfixer
File metadata and controls
executable file
·65 lines (56 loc) · 2.43 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
60
61
62
63
64
65
#!/bin/bash
# blocknotify script to disable mining when notary not eligible for easy mining
#
# Add to ~/.komodo/komodo.conf:
#
# blocknotify=/home/komodo/nntools/minerfixer %s
#
# @author webworker01
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
# Check if synced
getsynced=$($komodocli getinfo | jq .synced)
if [[ -z $getsynced || "$getsynced" == "null" || "$getsynced" == "false" ]]; then
log "minerfixer" "not synced yet" "red" "echo"
exit 0
fi
lastgen=$($komodocli listtransactions "*" 777 | jq '[.[] | select(.generated==true)] | .[-1]')
if [[ "$lastgen" != "null" ]]; then
confirmations=$(jq .confirmations <<< $lastgen)
rawconfirmations=$(jq .rawconfirmations <<< $lastgen)
lastamount=$(jq .amount <<< $lastgen)
lasthash=$(jq -r .blockhash <<< $lastgen)
lasttxid=$(jq -r .txid <<< $lastgen)
lastheight=$($komodocli getblockheader $lasthash | jq -r .height)
log "minerfixer" "Last Amt:${lastamount} Ht:${lastheight} RawConfs:${rawconfirmations} Confs:${confirmations}" "green" "echo"
if (( $rawconfirmations == 1 )); then
log "minerfixer" "[[ Block found! ]] Height: ${lastheight} Amount: ${lastamount} TxID: ${lasttxid}" "red"
elif (( $rawconfirmations == 2 )); then
log "minerfixer" "[[ Block found! ]]" "green" "echo"
#between 3 and 64 confirmations go into power saving mode
elif (( ($rawconfirmations > 2 && $rawconfirmations < 65) )); then
$komodocli setgenerate false
if (( $rawconfirmations == 3 )); then
log "minerfixer" "energy saving mode" "green"
else
log "minerfixer" "energy saving mode" "green" "echo"
fi
#setgenerate true upon eligibility and every 65 blocks after that as failsafe
elif (( $rawconfirmations % 65 == 0 )); then
log "minerfixer" "setgenerate true (${rawconfirmations} confs)"
$komodocli setgenerate true ${miner_threads}
# Verify mining when it should be
else
mining=$($komodocli getmininginfo | jq -r .generate)
if [[ "${mining}" == "false" ]]; then
log "minerfixer" "Should have been mining but wasn't - setgenerate true" "red"
$komodocli setgenerate true ${miner_threads}
else
log "minerfixer" "mining.." "green" "echo"
fi
fi
else
log "minerfixer" "could not get last mined tx! setgenerate true"
$komodocli setgenerate true ${miner_threads}
fi