Made all mining threads low-priority.
This commit is contained in:
@@ -15,6 +15,7 @@ log = "0.4.14"
|
|||||||
simple_logger = "1.11.0"
|
simple_logger = "1.11.0"
|
||||||
rust-crypto = "^0.2"
|
rust-crypto = "^0.2"
|
||||||
num_cpus = "1.13.0"
|
num_cpus = "1.13.0"
|
||||||
|
thread-priority = "0.2.1"
|
||||||
byteorder = "1.3.2"
|
byteorder = "1.3.2"
|
||||||
web-view = { version = "0.7.2", features = [] }
|
web-view = { version = "0.7.2", features = [] }
|
||||||
tinyfiledialogs = "3.3.10"
|
tinyfiledialogs = "3.3.10"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use std::time::{Duration, Instant};
|
|||||||
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
||||||
|
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
|
use thread_priority::*;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use web_view::*;
|
use web_view::*;
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
@@ -420,6 +421,7 @@ fn create_key(context: Arc<Mutex<Context>>) {
|
|||||||
let mining = mining.clone();
|
let mining = mining.clone();
|
||||||
let miners_count = miners_count.clone();
|
let miners_count = miners_count.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
let _ = set_current_thread_priority(ThreadPriority::Min);
|
||||||
miners_count.fetch_add(1, Ordering::Relaxed);
|
miners_count.fetch_add(1, Ordering::Relaxed);
|
||||||
match generate_key(KEYSTORE_DIFFICULTY, mining.clone()) {
|
match generate_key(KEYSTORE_DIFFICULTY, mining.clone()) {
|
||||||
None => {
|
None => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crypto::sha2::Sha256;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use num_cpus;
|
use num_cpus;
|
||||||
|
use thread_priority::*;
|
||||||
|
|
||||||
use crate::{Block, Bytes, Context, hash_is_good};
|
use crate::{Block, Bytes, Context, hash_is_good};
|
||||||
use crate::blockchain::blockchain::BlockQuality;
|
use crate::blockchain::blockchain::BlockQuality;
|
||||||
@@ -142,6 +143,7 @@ impl Miner {
|
|||||||
let mining = mining.clone();
|
let mining = mining.clone();
|
||||||
let live_threads = live_threads.clone();
|
let live_threads = live_threads.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
let _ = set_current_thread_priority(ThreadPriority::Min);
|
||||||
live_threads.fetch_add(1, Ordering::SeqCst);
|
live_threads.fetch_add(1, Ordering::SeqCst);
|
||||||
match find_hash(&mut Sha256::new(), block, mining.clone()) {
|
match find_hash(&mut Sha256::new(), block, mining.clone()) {
|
||||||
None => {
|
None => {
|
||||||
|
|||||||
Reference in New Issue
Block a user