diff options
author | Dion Ahmetaj <ahmetajd@coned.com> | 2017-02-02 12:33:34 -0500 |
---|---|---|
committer | Dion Ahmetaj <Dion Ahmetaj> | 2017-02-10 18:07:40 -0500 |
commit | 0b1045ed7d4a8116489996de49eb0940eee03015 (patch) | |
tree | 119ad43fd168d97788ee58a1e8e0b02c4851adc0 /src/cryptonote_basic/miner.cpp | |
parent | Moved setting of previous process times to block where background mining is s... (diff) | |
download | monero-0b1045ed7d4a8116489996de49eb0940eee03015.tar.xz |
Moved around checking of AC power in order to bail quicker to sleep if not plugged in.
Diffstat (limited to 'src/cryptonote_basic/miner.cpp')
-rw-r--r-- | src/cryptonote_basic/miner.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 9ae56be38..08877c260 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -574,7 +574,9 @@ namespace cryptonote MGINFO(__func__ << " : background miner thread interrupted "); continue; // if interrupted because stop called, loop should end .. } - + + bool on_ac_power = ac_line_status(); + if( m_is_background_mining_started ) { // figure out if we need to stop, and monitor mining usage @@ -599,9 +601,9 @@ namespace cryptonote uint64_t process_diff = (current_process_time - previous_process_time); uint8_t idle_percentage = get_percent_of_total(idle_diff, total_diff); uint8_t process_percentage = get_percent_of_total(process_diff, total_diff); - bool on_ac_power = ac_line_status(); + MGINFO(__func__ << " : idle percentage is " << unsigned(idle_percentage) << "\%, miner percentage is " << unsigned(process_percentage) << "\%, ac power : " << on_ac_power); - if( idle_percentage + process_percentage < get_idle_threshold() || !ac_line_status() ) + if( idle_percentage + process_percentage < get_idle_threshold() || !on_ac_power ) { MGINFO(__func__ << " : cpu is " << unsigned(idle_percentage) << "% idle, idle threshold is " << unsigned(get_idle_threshold()) << "\%, ac power : " << on_ac_power << ", background mining stopping, thanks for your contribution!"); m_is_background_mining_started = false; @@ -627,7 +629,7 @@ namespace cryptonote prev_total_time = current_total_time; prev_idle_time = current_idle_time; } - else + else if( on_ac_power ) { // figure out if we need to start |