Added mining threads count option.
This commit is contained in:
@@ -32,7 +32,7 @@ impl DnsFilter for BlockchainFilter {
|
||||
subdomain = String::from(parts[2]);
|
||||
}
|
||||
}
|
||||
debug!("Searching domain {} and record {}", &search, &subdomain);
|
||||
debug!("Searching record type '{:?}', name '{}' for domain '{}'", &qtype, &subdomain, &search);
|
||||
|
||||
let data = self.context.lock().unwrap().chain.get_domain_info(&search);
|
||||
match data {
|
||||
@@ -129,6 +129,7 @@ impl DnsFilter for BlockchainFilter {
|
||||
}
|
||||
}
|
||||
|
||||
//debug!("Answers: {:?}", &answers);
|
||||
return if !answers.is_empty() {
|
||||
// Create DnsPacket
|
||||
let mut packet = DnsPacket::new();
|
||||
|
||||
@@ -69,7 +69,7 @@ impl fmt::Debug for Transaction {
|
||||
|
||||
impl Serialize for Transaction {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where S: Serializer {
|
||||
let mut structure = serializer.serialize_struct("Transaction", 4).unwrap();
|
||||
let mut structure = serializer.serialize_struct("Transaction", 5).unwrap();
|
||||
structure.serialize_field("identity", &self.identity)?;
|
||||
structure.serialize_field("confirmation", &self.confirmation)?;
|
||||
structure.serialize_field("method", &self.method)?;
|
||||
|
||||
+6
-1
@@ -157,7 +157,12 @@ pub fn create_key(context: Arc<Mutex<Context>>) {
|
||||
let mining = Arc::new(AtomicBool::new(true));
|
||||
let miners_count = Arc::new(AtomicUsize::new(0));
|
||||
{ context.lock().unwrap().bus.post(Event::KeyGeneratorStarted); }
|
||||
for _cpu in 0..num_cpus::get() {
|
||||
let threads = context.lock().unwrap().settings.mining.threads;
|
||||
let threads = match threads {
|
||||
0 => num_cpus::get(),
|
||||
_ => threads
|
||||
};
|
||||
for _cpu in 0..threads {
|
||||
let context = Arc::clone(&context);
|
||||
let mining = mining.clone();
|
||||
let miners_count = miners_count.clone();
|
||||
|
||||
+7
-2
@@ -142,8 +142,13 @@ impl Miner {
|
||||
let thread_spawn_interval = Duration::from_millis(10);
|
||||
let live_threads = Arc::new(AtomicU32::new(0u32));
|
||||
let cpus = num_cpus::get();
|
||||
debug!("Starting {} threads for mining", cpus);
|
||||
for _cpu in 0..cpus {
|
||||
let threads = context.lock().unwrap().settings.mining.threads;
|
||||
let threads = match threads {
|
||||
0 => cpus,
|
||||
_ => threads
|
||||
};
|
||||
debug!("Starting {} threads for mining", threads);
|
||||
for _cpu in 0..threads {
|
||||
let context = Arc::clone(&context);
|
||||
let job = job.clone();
|
||||
let mining = Arc::clone(&mining);
|
||||
|
||||
+10
-1
@@ -21,6 +21,8 @@ pub struct Settings {
|
||||
pub peers: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub dns: Dns,
|
||||
#[serde(default)]
|
||||
pub mining: Mining,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -69,7 +71,8 @@ impl Default for Settings {
|
||||
listen: String::from("[::]:4244"),
|
||||
public: false,
|
||||
peers: vec![],
|
||||
dns: Default::default()
|
||||
dns: Default::default(),
|
||||
mining: Mining::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +92,12 @@ impl Default for Dns {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Mining {
|
||||
#[serde(default)]
|
||||
pub threads: usize
|
||||
}
|
||||
|
||||
fn default_listen() -> String {
|
||||
String::from("[::]:4244")
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="is-clipped">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
html {
|
||||
overflow-y: auto;
|
||||
min-width: 768px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 10pt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user