-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix gui miner, bump version for release
- Loading branch information
Showing
6 changed files
with
41 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "plain_bitnames_app" | ||
version = "0.5.1" | ||
version = "0.5.2" | ||
edition = "2021" | ||
authors = [ "Ash Manning <[email protected]>" ] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
use std::sync::{ | ||
atomic::{self, AtomicBool}, | ||
Arc, | ||
}; | ||
|
||
use eframe::egui::{self, Button}; | ||
|
||
use crate::app::App; | ||
use eframe::egui; | ||
|
||
pub struct Miner; | ||
#[derive(Debug)] | ||
pub struct Miner { | ||
running: Arc<AtomicBool>, | ||
} | ||
|
||
impl Default for Miner { | ||
fn default() -> Self { | ||
Self | ||
Self { | ||
running: Arc::new(AtomicBool::new(false)), | ||
} | ||
} | ||
} | ||
|
||
impl Miner { | ||
pub fn show(&mut self, app: &mut App, ui: &mut egui::Ui) { | ||
pub fn show(&mut self, app: &App, ui: &mut egui::Ui) { | ||
let block_height = app.node.get_height().unwrap_or(0); | ||
let best_hash = app.node.get_best_hash().unwrap_or([0; 32].into()); | ||
ui.label("Block height: "); | ||
ui.monospace(format!("{block_height}")); | ||
ui.label("Best hash: "); | ||
let best_hash = &format!("{best_hash}")[0..8]; | ||
ui.monospace(format!("{best_hash}...")); | ||
if ui.button("mine").clicked() { | ||
let _result = app.mine(None); | ||
|
||
let running = self.running.load(atomic::Ordering::SeqCst); | ||
if ui.add_enabled(!running, Button::new("Mine")).clicked() { | ||
self.running.store(true, atomic::Ordering::SeqCst); | ||
app.runtime.spawn({ | ||
let app = app.clone(); | ||
let running = self.running.clone(); | ||
async move { | ||
tracing::debug!("Mining..."); | ||
let mining_result = app.mine(None).await; | ||
running.store(false, atomic::Ordering::SeqCst); | ||
if let Err(err) = mining_result { | ||
tracing::error!("{:#}", anyhow::Error::new(err)) | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "plain_bitnames" | ||
version = "0.5.1" | ||
version = "0.5.2" | ||
edition = "2021" | ||
authors = [ "Ash Manning <[email protected]>" ] | ||
|
||
|