I've made a Linux script to implement Sweet Spot block targetting,
since the buldozers come, f**k up the block reward and go.
In the last few days there was spikes of the Network hashrate as high of 120 Mh/s,
so there is no point of mining at full speed, when the Network is so far away from ideal speed for ~50 XMG per block.
Here is the code of
xmg-sweet.sh that I've been testing for a week now on two of my Ubuntu miners:
#!/bin/bash
#
# Sweet Spot block targeting script v0.1
#
### USER DEFINED BLOCK VALUES
# Text file to store max cpu threads
threadsfile=/home/urban/sweet-spot/cpuid.txt
# XMG block value to triger full speed mining
trgtfull=8
# XMG block value to triger mining at 50%
trgthalf=6
###
echo -e "\nPress [CTRL+C] to stop Sweet Spot block targetting...\n"
# INFINITE LOOP #
while :
do
if [ -f $threadsfile ]; then
cpus=$(<$threadsfile)
else
grep -c processor /proc/cpuinfo > "$threadsfile"
cpus=$(<$threadsfile)
fi
maxuse=$((cpus*100))
avrguse=$((maxuse/2))
minuse=$((maxuse/5))
minerpid=$(pidof minerd)
netblock=$(curl -s -k --retry 3 --retry-delay 30 --retry-max-time 15 http://multipools.info/xmg-block-net-info.txt)
net=$(echo $netblock | cut -d "|" -f 1)
bvalue=$(echo $netblock | cut -d "|" -f 2)
echo " ---------------------------------------------------------"
echo -e " | Current Block reward: \e[1;32m$bvalue\e[39;0m XMG. Network speed: \e[1;32m$net\e[39;0m Mh/s."
if [ $(perl -e "($bvalue >= $trgtfull) ? print 1 : print 0") -eq 1 ]; then
echo " | Switching to Full Speed mining at 100%!"
echo " ---------------------------------------------------------"
# kill cpulimit => full speed
killall -9 cpulimit
elif [ $(perl -e "($bvalue >= $trgthalf) ? print 1 : print 0") -eq 1 ]; then
echo " | Switching to Power Efficient mining at 50%!"
echo " ---------------------------------------------------------"
# cpulimit @ 50% cpu
killall -9 cpulimit
cpulimit -p $minerpid -b -z -l $avrguse
else
echo " | Switching to Power Efficient mining at 20%!"
echo " ---------------------------------------------------------"
# cpulimit @ 20% cpu
killall -9 cpulimit
cpulimit -p $minerpid -b -z -l $minuse
fi
sleep 1m
done
The values defining at which block value the miner will go full speed is
trgtfull=8 and
trgthalf=6 for 50% restricted mining.
In order to work the script needs
cpulimit.
You can install it in Ubuntu:
sudo apt-get update && sudo apt-get install -y cpulimit
I've made an folder, inside of my home dir called
sweet-spot and created there the
xmg-sweet.shby pasting the contents in a newly created file
Then I've made the script executable
To run it continuously, I've started the script in separate screen so now I can monitor miner's screen and sweet-spot screen when I needed.
screen -dmS sweet ~/sweet-spot/xmg-sweet.sh
To restore the sweet-spot screen use
Any comments and ideas are welcomed.