Small UI and log polishing.

pull/124/head
Revertron 3 years ago
parent 88404a635b
commit 8a8c2678ae

@ -1,6 +1,6 @@
[package]
name = "alfis"
version = "0.5.8"
version = "0.5.9"
authors = ["Revertron <alfis@revertron.com>"]
edition = "2018"
build = "build.rs"

@ -2,7 +2,7 @@
pub enum Event {
MinerStarted,
MinerStopped { success: bool, full: bool },
MinerStats { thread: usize, speed: u64, max_diff: u32, target_diff: u32 },
MinerStats { thread: u32, speed: u64, max_diff: u32, target_diff: u32 },
KeyGeneratorStarted,
KeyGeneratorStopped,
KeyCreated { path: String, public: String, hash: String },

@ -247,8 +247,9 @@ impl Miner {
let threads = match threads {
0 => cpus,
_ => threads
};
} as u32;
debug!("Starting {} threads for mining", threads);
debug!("Mining block {}", serde_json::to_string(&job.block).unwrap());
let thread_spawn_interval = Duration::from_millis(100);
let live_threads = Arc::new(AtomicU32::new(0u32));
for cpu in 0..threads {
@ -259,12 +260,14 @@ impl Miner {
thread::spawn(move || {
live_threads.fetch_add(1, Ordering::SeqCst);
if lower {
setup_miner_thread(cpu as u32);
setup_miner_thread(cpu);
}
let full = job.block.transaction.is_some();
match find_hash(Arc::clone(&context), job.block, Arc::clone(&mining), cpu) {
None => {
debug!("Mining was cancelled");
if live_threads.load(Ordering::Relaxed) >= threads {
debug!("Mining was cancelled");
}
let count = live_threads.fetch_sub(1, Ordering::SeqCst);
// If this is the last thread, but mining was not stopped by another thread
if count == 1 {
@ -303,7 +306,7 @@ impl Miner {
}
}
fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<AtomicBool>, thread: usize) -> Option<Block> {
fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<AtomicBool>, thread: u32) -> Option<Block> {
let target_diff = block.difficulty;
let full = block.transaction.is_some();
let mut digest = Blakeout::new();
@ -329,7 +332,6 @@ fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<Atomic
continue;
}
debug!("Mining block {}", serde_json::to_string(&block).unwrap());
let mut time = Instant::now();
let mut prev_nonce = 0;
for nonce in 0..u64::MAX {
@ -364,7 +366,7 @@ fn find_hash(context: Arc<Mutex<Context>>, mut block: Block, running: Arc<Atomic
if let Ok(context) = context.try_lock() {
if context.chain.get_height() >= block.index {
if !full {
info!("Blockchain changed while mining signing block, dropping work");
//trace!("Blockchain changed while mining signing block, dropping work");
running.store(false, Ordering::SeqCst);
return None;
}

@ -255,7 +255,7 @@ fn action_loaded(context: &Arc<Mutex<Context>>, web_view: &mut WebView<()>) {
}
false => {
event_handle_info(&handle, "Mining finished without result.");
s.push_str(" showSuccess('Mining unsuccessful, sorry.')");
s.push_str(" showWarning('Mining unsuccessful, sorry.')");
}
}
}
@ -354,7 +354,7 @@ fn load_domains(context: &mut MutexGuard<Context>, handle: &Handle<()>) {
web_view.eval("clearMyDomains();")
});
let domains = context.chain.get_my_domains(context.get_keystore());
debug!("Domains: {:?}", &domains.values());
//debug!("Domains: {:?}", &domains.values());
for (_identity, (domain, timestamp, data)) in domains {
let d = serde_json::to_string(&data).unwrap();
let command = format!("addMyDomain('{}', {}, {}, '{}');", &domain, timestamp, timestamp + DOMAIN_LIFETIME, &d);
@ -608,8 +608,8 @@ impl Status {
Status { mining: false, syncing: false, synced_blocks: 0, sync_height: 0, nodes_connected: 0, chain_height: 0, max_diff: 0, speed }
}
fn set_thread_speed(&mut self, thread: usize, speed: u64) {
self.speed[thread] = speed;
fn set_thread_speed(&mut self, thread: u32, speed: u64) {
self.speed[thread as usize] = speed;
}
fn get_speed(&self) -> u64 {

@ -187,7 +187,7 @@
<div id="modal_dialog" class="modal">
<div class="modal-background"></div>
<div class="modal-content">
<div class="modal-content" style="width: auto;">
<div class="box">
<p id="modal_text" class="is-centered">Do you really want to cancel mining?</p>
<br/>

@ -6,6 +6,7 @@ var myDomains = [];
var currentZone;
var currentSelectedKey = -1;
var keysLoaded = [];
var stateMining = false;
document.addEventListener('click', function (event) {
closeDropdowns();
@ -482,8 +483,10 @@ function showMiningIndicator(visible, blue) {
var indicator = document.getElementById("busy_indicator");
var parent = document.getElementById("indicator_parent");
var add = "";
stateMining = true;
if (blue) {
add = " busy_blue";
stateMining = false;
}
if (visible) {
indicator.className = 'busy_indicator' + add;
@ -500,9 +503,11 @@ function showMiningIndicator(visible, blue) {
}
function miningIndicatorClick(element) {
showModalDialog("Do you really want to stop mining?", function() {
external.invoke(JSON.stringify({cmd: 'stopMining'}));
});
if (stateMining) {
showModalDialog("Do you really want to stop mining?", function() {
external.invoke(JSON.stringify({cmd: 'stopMining'}));
});
}
}
function setLeftStatusBarText(text) {

Loading…
Cancel
Save