My auto-switching miner bot is growing and needs some better handling of the configuration.
That is why I have decided to move the config into a dedicated rig_config.py file
.
To make it short:
Import your config file:
#If your file is called rig_config.py and is in the same folder as the script using it:
import rig_config
Define your variables in the config file:
#Current values for whattomine parameters - will get them dynamically
#Ethash
eth={
'enabled': 'true',
'hash_rate': '70.0', #Mh/s
'power': '270'
}
#Groestl
gro={
'enabled': 'true',
'hash_rate': '116.0', #Mh/s
'power': '270'
}
Reference them correctly in your script:
print rig_config.installed
results = sorted(rig_config.installed, key=lambda x:x['profitability24'], reverse = True)
Final notes
I hope you liked my little tutorial about a basic concept of Python programming.
There are actually many ways to do this, but I find this to be the quickest and simplest way.
Of course this is not the most secure and final solution, since arbitrary code could potentially be inserted into the config file and the interpreter, when importing it, would execute it. Therefore if you are planning to include this into an enterprise level application, think about security requirements and do your research!
Future plans
The reason I did this was because I want to parametrize further my actual mining rig script.
The plan is to have the script automatically optimize itself gathering the actual hashrate from the pools and updating its own config file!
In this way I am sure to always be switching to the most profitable algorithm and I could introduce multi-pool & multi-algo switching.
Working on it!