2
0
mirror of https://github.com/Revertron/Alfis synced 2024-11-03 15:40:19 +00:00

Added mining threads count option.

This commit is contained in:
Revertron 2021-03-29 11:10:48 +02:00
parent 5aab83613e
commit 4e0b0b3d1c
8 changed files with 53 additions and 11 deletions

View File

@ -1,18 +1,35 @@
# Settings
# Main settings
# The hash of first block in a chain to know with which nodes to work
origin = "00000102C2F9BFD2803284D93327F089D60FC72A06F19AF2384567F2646B8348"
# A path to your key file to load autamatically
key_file = "default.key"
# Your node will listen on that address for other nodes to connect
listen = "[::]:4244"
# Set true if you want your IP to participate in peer-exchange, or false otherwise
public = true
# Bootstrap nodes
# All bootstap nodes
#peers = ["test-ip4.alfis.name:4244", "test-ip6.alfis.name:4244"]
peers = ["[300:1251::1]:4244"]
# Yggdrasil nodes only
peers = ["test-ip6.alfis.name:4244"]
# DNS server options
[dns]
# Your DNS resolver will be listening on this address and port (Usual port is 53)
listen = "127.0.0.1:5300"
# How many threads to spawn by DNS server
threads = 20
#AdGuard DNS servers to filter ads and trackers
# AdGuard DNS servers to filter ads and trackers
#forwarders = ["94.140.14.14:53", "94.140.15.15:53"]
# Wyrd servers
forwarders = ["[301:2522::53]:53", "[303:8b1a::53]:53"]
#forwarders = ["[301:2522::53]:53", "[301:2923::53]:53", "94.140.14.14:53", "94.140.15.15:53"]
# Cloudflare servers
#forwarders = ["1.1.1.1:53", "1.0.0.1:53"]
#Mining options
[mining]
# How many CPU threads to spawn for mining
threads = 0

View File

@ -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();

View File

@ -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)?;

View File

@ -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();

View File

@ -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);

View File

@ -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")
}

View File

@ -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">

View File

@ -1,3 +1,8 @@
html {
overflow-y: auto;
min-width: 768px;
}
.container {
margin: 10pt;
}