diff --git a/Cargo.toml b/Cargo.toml index a22ea67..a628a02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/main.rs b/src/main.rs index 98189f7..643570e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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>) { 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 => { diff --git a/src/miner.rs b/src/miner.rs index 2c7c6a3..050c802 100644 --- a/src/miner.rs +++ b/src/miner.rs @@ -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 => {