Background/smart mining. If a users' computer is plugged into a power

source, and CPU has been idle for some time, then begin mining to some
threshold (don't destroy the users' CPU).

This patch only supports windows and linux (I've only tested on Win64 and
Ubuntu).

The variables currently default to pretty conservative values (i.e. 20%
CPU mining threshold).
This commit is contained in:
Dion Ahmetaj
2017-01-14 22:20:54 -05:00
parent cb54eeaa31
commit 345ed4823c
8 changed files with 459 additions and 18 deletions

View File

@@ -271,17 +271,24 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
if(testnet)
std::cout << "Mining to a testnet address, make sure this is intentional!" << std::endl;
uint64_t threads_count = 1;
if(args.size() > 2)
bool do_background_mining = false;
if(args.size() > 3)
{
return false;
}
else if(args.size() == 2)
if(args.size() == 3)
{
do_background_mining = args[2] == "true";
}
if(args.size() >= 2)
{
bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]);
threads_count = (ok && 0 < threads_count) ? threads_count : 1;
}
m_executor.start_mining(adr, threads_count, testnet);
m_executor.start_mining(adr, threads_count, testnet, do_background_mining);
return true;
}