Made all mining threads low-priority.

pull/3/head
Revertron 3 years ago
parent b0e78edb3d
commit c5d20d2e00

@ -15,6 +15,7 @@ log = "0.4.14"
simple_logger = "1.11.0"
rust-crypto = "^0.2"
num_cpus = "1.13.0"
thread-priority = "0.2.1"
byteorder = "1.3.2"
web-view = { version = "0.7.2", features = [] }
tinyfiledialogs = "3.3.10"

@ -17,6 +17,7 @@ use std::time::{Duration, Instant};
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
use rand::RngCore;
use thread_priority::*;
use serde::Deserialize;
use web_view::*;
use getopts::Options;
@ -420,6 +421,7 @@ fn create_key(context: Arc<Mutex<Context>>) {
let mining = mining.clone();
let miners_count = miners_count.clone();
thread::spawn(move || {
let _ = set_current_thread_priority(ThreadPriority::Min);
miners_count.fetch_add(1, Ordering::Relaxed);
match generate_key(KEYSTORE_DIFFICULTY, mining.clone()) {
None => {

@ -9,6 +9,7 @@ use crypto::sha2::Sha256;
#[allow(unused_imports)]
use log::{debug, error, info, trace, warn};
use num_cpus;
use thread_priority::*;
use crate::{Block, Bytes, Context, hash_is_good};
use crate::blockchain::blockchain::BlockQuality;
@ -142,6 +143,7 @@ impl Miner {
let mining = mining.clone();
let live_threads = live_threads.clone();
thread::spawn(move || {
let _ = set_current_thread_priority(ThreadPriority::Min);
live_threads.fetch_add(1, Ordering::SeqCst);
match find_hash(&mut Sha256::new(), block, mining.clone()) {
None => {

Loading…
Cancel
Save