Skip to content

Instantly share code, notes, and snippets.

@meowsbits
Created May 28, 2020 12:42
Show Gist options
  • Save meowsbits/36b8bb2ccdce54ab3ab4599d6de50ed6 to your computer and use it in GitHub Desktop.
Save meowsbits/36b8bb2ccdce54ab3ab4599d6de50ed6 to your computer and use it in GitHub Desktop.
When and if geth's CPU miner drops below floor hashrate, switch off and restart mining after an interval.
var hashrateFloor = 20000;
for (;true;) {
var sleepInterval = 60;
if (!eth.mining) {
console.log(Date(), "starting miner")
miner.start();
sleepInterval = 60*10;
}
var hashrate = miner.getHashrate();
console.log(Date() , "hashrate", hashrate);
if (hashrate < hashrateFloor) {
console.log(Date(), "hashrate below floor, stopping miner")
miner.stop();
sleepInterval = 60*30;
}
admin.sleep(sleepInterval);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment