mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 08:51:08 +03:00
Mining tui updates (#3584)
* add column ordering, set mining workers table to sort the connected workers to the top by default * add column ordering, set mining workers table to sort the connected workers to the top by default * Mining TUI fixes and updates
This commit is contained in:
parent
64b2fddbf1
commit
059e6ad545
3 changed files with 55 additions and 63 deletions
|
@ -130,8 +130,12 @@ pub struct StratumStats {
|
||||||
pub network_difficulty: u64,
|
pub network_difficulty: u64,
|
||||||
/// cuckoo size of last share submitted
|
/// cuckoo size of last share submitted
|
||||||
pub edge_bits: u16,
|
pub edge_bits: u16,
|
||||||
|
/// Number of blocks found by all workers
|
||||||
|
pub blocks_found: u16,
|
||||||
/// current network Hashrate (for edge_bits)
|
/// current network Hashrate (for edge_bits)
|
||||||
pub network_hashrate: f64,
|
pub network_hashrate: f64,
|
||||||
|
/// The minimum acceptable share difficulty to request from miners
|
||||||
|
pub minimum_share_difficulty: u64,
|
||||||
/// Individual worker status
|
/// Individual worker status
|
||||||
pub worker_stats: Vec<WorkerStats>,
|
pub worker_stats: Vec<WorkerStats>,
|
||||||
}
|
}
|
||||||
|
@ -271,8 +275,10 @@ impl Default for StratumStats {
|
||||||
num_workers: 0,
|
num_workers: 0,
|
||||||
block_height: 0,
|
block_height: 0,
|
||||||
network_difficulty: 0,
|
network_difficulty: 0,
|
||||||
edge_bits: 0,
|
edge_bits: 32,
|
||||||
|
blocks_found: 0,
|
||||||
network_hashrate: 0.0,
|
network_hashrate: 0.0,
|
||||||
|
minimum_share_difficulty: 1,
|
||||||
worker_stats: Vec::new(),
|
worker_stats: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -714,7 +714,7 @@ impl WorkersList {
|
||||||
let mut worker_stats = WorkerStats::default();
|
let mut worker_stats = WorkerStats::default();
|
||||||
worker_stats.is_connected = true;
|
worker_stats.is_connected = true;
|
||||||
worker_stats.id = worker_id.to_string();
|
worker_stats.id = worker_id.to_string();
|
||||||
worker_stats.pow_difficulty = 1; // XXX TODO
|
worker_stats.pow_difficulty = stratum_stats.minimum_share_difficulty;
|
||||||
stratum_stats.worker_stats.push(worker_stats);
|
stratum_stats.worker_stats.push(worker_stats);
|
||||||
stratum_stats.num_workers = workers_list.len();
|
stratum_stats.num_workers = workers_list.len();
|
||||||
worker_id
|
worker_id
|
||||||
|
@ -885,6 +885,7 @@ impl StratumServer {
|
||||||
let mut stratum_stats = self.stratum_stats.write();
|
let mut stratum_stats = self.stratum_stats.write();
|
||||||
stratum_stats.is_running = true;
|
stratum_stats.is_running = true;
|
||||||
stratum_stats.edge_bits = (global::min_edge_bits() + 1) as u16;
|
stratum_stats.edge_bits = (global::min_edge_bits() + 1) as u16;
|
||||||
|
stratum_stats.minimum_share_difficulty = self.config.minimum_share_difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!(
|
warn!(
|
||||||
|
|
|
@ -50,7 +50,7 @@ enum StratumWorkerColumn {
|
||||||
impl StratumWorkerColumn {
|
impl StratumWorkerColumn {
|
||||||
fn _as_str(&self) -> &str {
|
fn _as_str(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
StratumWorkerColumn::Id => "Worker ID",
|
StratumWorkerColumn::Id => "ID",
|
||||||
StratumWorkerColumn::IsConnected => "Connected",
|
StratumWorkerColumn::IsConnected => "Connected",
|
||||||
StratumWorkerColumn::LastSeen => "Last Seen",
|
StratumWorkerColumn::LastSeen => "Last Seen",
|
||||||
StratumWorkerColumn::PowDifficulty => "PowDifficulty",
|
StratumWorkerColumn::PowDifficulty => "PowDifficulty",
|
||||||
|
@ -85,19 +85,21 @@ impl TableViewItem<StratumWorkerColumn> for WorkerStats {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmp(&self, _other: &Self, column: StratumWorkerColumn) -> Ordering
|
fn cmp(&self, other: &Self, column: StratumWorkerColumn) -> Ordering
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
match column {
|
match column {
|
||||||
StratumWorkerColumn::Id => Ordering::Equal,
|
StratumWorkerColumn::Id => self.id.cmp(&other.id),
|
||||||
StratumWorkerColumn::IsConnected => Ordering::Equal,
|
StratumWorkerColumn::IsConnected => self.is_connected.cmp(&other.is_connected),
|
||||||
StratumWorkerColumn::LastSeen => Ordering::Equal,
|
StratumWorkerColumn::LastSeen => self.last_seen.cmp(&other.last_seen),
|
||||||
StratumWorkerColumn::PowDifficulty => Ordering::Equal,
|
StratumWorkerColumn::PowDifficulty => self.pow_difficulty.cmp(&other.pow_difficulty),
|
||||||
StratumWorkerColumn::NumAccepted => Ordering::Equal,
|
StratumWorkerColumn::NumAccepted => self.num_accepted.cmp(&other.num_accepted),
|
||||||
StratumWorkerColumn::NumRejected => Ordering::Equal,
|
StratumWorkerColumn::NumRejected => self.num_rejected.cmp(&other.num_rejected),
|
||||||
StratumWorkerColumn::NumStale => Ordering::Equal,
|
StratumWorkerColumn::NumStale => self.num_stale.cmp(&other.num_stale),
|
||||||
StratumWorkerColumn::NumBlocksFound => Ordering::Equal,
|
StratumWorkerColumn::NumBlocksFound => {
|
||||||
|
self.num_blocks_found.cmp(&other.num_blocks_found)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +107,7 @@ impl TableViewItem<StratumWorkerColumn> for WorkerStats {
|
||||||
enum DiffColumn {
|
enum DiffColumn {
|
||||||
Height,
|
Height,
|
||||||
Hash,
|
Hash,
|
||||||
PoWType,
|
|
||||||
Difficulty,
|
Difficulty,
|
||||||
SecondaryScaling,
|
|
||||||
Time,
|
Time,
|
||||||
Duration,
|
Duration,
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,7 @@ impl DiffColumn {
|
||||||
match *self {
|
match *self {
|
||||||
DiffColumn::Height => "Height",
|
DiffColumn::Height => "Height",
|
||||||
DiffColumn::Hash => "Hash",
|
DiffColumn::Hash => "Hash",
|
||||||
DiffColumn::PoWType => "Type",
|
|
||||||
DiffColumn::Difficulty => "Network Difficulty",
|
DiffColumn::Difficulty => "Network Difficulty",
|
||||||
DiffColumn::SecondaryScaling => "Sec. Scaling",
|
|
||||||
DiffColumn::Time => "Block Time",
|
DiffColumn::Time => "Block Time",
|
||||||
DiffColumn::Duration => "Duration",
|
DiffColumn::Duration => "Duration",
|
||||||
}
|
}
|
||||||
|
@ -130,35 +128,26 @@ impl TableViewItem<DiffColumn> for DiffBlock {
|
||||||
fn to_column(&self, column: DiffColumn) -> String {
|
fn to_column(&self, column: DiffColumn) -> String {
|
||||||
let naive_datetime = NaiveDateTime::from_timestamp(self.time as i64, 0);
|
let naive_datetime = NaiveDateTime::from_timestamp(self.time as i64, 0);
|
||||||
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
|
let datetime: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
|
||||||
let pow_type = if self.is_secondary {
|
|
||||||
String::from("Secondary")
|
|
||||||
} else {
|
|
||||||
String::from("Primary")
|
|
||||||
};
|
|
||||||
|
|
||||||
match column {
|
match column {
|
||||||
DiffColumn::Height => self.block_height.to_string(),
|
DiffColumn::Height => self.block_height.to_string(),
|
||||||
DiffColumn::Hash => self.block_hash.to_string(),
|
DiffColumn::Hash => self.block_hash.to_string(),
|
||||||
DiffColumn::PoWType => pow_type,
|
|
||||||
DiffColumn::Difficulty => self.difficulty.to_string(),
|
DiffColumn::Difficulty => self.difficulty.to_string(),
|
||||||
DiffColumn::SecondaryScaling => self.secondary_scaling.to_string(),
|
|
||||||
DiffColumn::Time => format!("{}", datetime),
|
DiffColumn::Time => format!("{}", datetime),
|
||||||
DiffColumn::Duration => format!("{}s", self.duration),
|
DiffColumn::Duration => format!("{}s", self.duration),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmp(&self, _other: &Self, column: DiffColumn) -> Ordering
|
fn cmp(&self, other: &Self, column: DiffColumn) -> Ordering
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
match column {
|
match column {
|
||||||
DiffColumn::Height => Ordering::Equal,
|
DiffColumn::Height => self.block_height.cmp(&other.block_height),
|
||||||
DiffColumn::Hash => Ordering::Equal,
|
DiffColumn::Hash => self.block_hash.cmp(&other.block_hash),
|
||||||
DiffColumn::PoWType => Ordering::Equal,
|
DiffColumn::Difficulty => self.difficulty.cmp(&other.difficulty),
|
||||||
DiffColumn::Difficulty => Ordering::Equal,
|
DiffColumn::Time => self.time.cmp(&other.time),
|
||||||
DiffColumn::SecondaryScaling => Ordering::Equal,
|
DiffColumn::Duration => self.duration.cmp(&other.duration),
|
||||||
DiffColumn::Time => Ordering::Equal,
|
|
||||||
DiffColumn::Duration => Ordering::Equal,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,29 +174,31 @@ impl TUIMiningView {
|
||||||
.child(Panel::new(devices_button))
|
.child(Panel::new(devices_button))
|
||||||
.child(Panel::new(difficulty_button));
|
.child(Panel::new(difficulty_button));
|
||||||
|
|
||||||
let table_view = TableView::<WorkerStats, StratumWorkerColumn>::new()
|
let mut table_view = TableView::<WorkerStats, StratumWorkerColumn>::new()
|
||||||
.column(StratumWorkerColumn::Id, "Worker ID", |c| c.width_percent(8))
|
.column(StratumWorkerColumn::Id, "ID", |c| c.width_percent(6))
|
||||||
.column(StratumWorkerColumn::IsConnected, "Connected", |c| {
|
.column(StratumWorkerColumn::IsConnected, "Connected", |c| {
|
||||||
c.width_percent(8)
|
c.width_percent(14)
|
||||||
})
|
})
|
||||||
.column(StratumWorkerColumn::LastSeen, "Last Seen", |c| {
|
.column(StratumWorkerColumn::LastSeen, "Last Seen", |c| {
|
||||||
c.width_percent(16)
|
c.width_percent(20)
|
||||||
})
|
})
|
||||||
.column(StratumWorkerColumn::PowDifficulty, "Pow Difficulty", |c| {
|
.column(StratumWorkerColumn::PowDifficulty, "Difficulty", |c| {
|
||||||
c.width_percent(12)
|
|
||||||
})
|
|
||||||
.column(StratumWorkerColumn::NumAccepted, "Num Accepted", |c| {
|
|
||||||
c.width_percent(10)
|
c.width_percent(10)
|
||||||
})
|
})
|
||||||
.column(StratumWorkerColumn::NumRejected, "Num Rejected", |c| {
|
.column(StratumWorkerColumn::NumAccepted, "Accepted", |c| {
|
||||||
c.width_percent(10)
|
c.width_percent(5)
|
||||||
})
|
})
|
||||||
.column(StratumWorkerColumn::NumStale, "Num Stale", |c| {
|
.column(StratumWorkerColumn::NumRejected, "Rejected", |c| {
|
||||||
c.width_percent(10)
|
c.width_percent(5)
|
||||||
|
})
|
||||||
|
.column(StratumWorkerColumn::NumStale, "Stale", |c| {
|
||||||
|
c.width_percent(5)
|
||||||
})
|
})
|
||||||
.column(StratumWorkerColumn::NumBlocksFound, "Blocks Found", |c| {
|
.column(StratumWorkerColumn::NumBlocksFound, "Blocks Found", |c| {
|
||||||
c.width_percent(10)
|
c.width_percent(35)
|
||||||
});
|
})
|
||||||
|
.default_column(StratumWorkerColumn::IsConnected);
|
||||||
|
table_view.sort_by(StratumWorkerColumn::IsConnected, Ordering::Greater);
|
||||||
|
|
||||||
let status_view = LinearLayout::new(Orientation::Vertical)
|
let status_view = LinearLayout::new(Orientation::Vertical)
|
||||||
.child(
|
.child(
|
||||||
|
@ -228,7 +219,7 @@ impl TUIMiningView {
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
LinearLayout::new(Orientation::Horizontal)
|
LinearLayout::new(Orientation::Horizontal)
|
||||||
.child(TextView::new(" ").with_name("stratum_edge_bits_status")),
|
.child(TextView::new(" ").with_name("stratum_blocks_found_status")),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
LinearLayout::new(Orientation::Horizontal)
|
LinearLayout::new(Orientation::Horizontal)
|
||||||
|
@ -270,17 +261,14 @@ impl TUIMiningView {
|
||||||
);
|
);
|
||||||
|
|
||||||
let diff_table_view = TableView::<DiffBlock, DiffColumn>::new()
|
let diff_table_view = TableView::<DiffBlock, DiffColumn>::new()
|
||||||
.column(DiffColumn::Height, "Height", |c| c.width_percent(10))
|
.column(DiffColumn::Height, "Height", |c| c.width_percent(15))
|
||||||
.column(DiffColumn::Hash, "Hash", |c| c.width_percent(10))
|
.column(DiffColumn::Hash, "Hash", |c| c.width_percent(15))
|
||||||
.column(DiffColumn::PoWType, "Type", |c| c.width_percent(10))
|
|
||||||
.column(DiffColumn::Difficulty, "Network Difficulty", |c| {
|
.column(DiffColumn::Difficulty, "Network Difficulty", |c| {
|
||||||
c.width_percent(15)
|
c.width_percent(15)
|
||||||
})
|
})
|
||||||
.column(DiffColumn::SecondaryScaling, "Sec. Scaling", |c| {
|
.column(DiffColumn::Time, "Block Time", |c| c.width_percent(30))
|
||||||
c.width_percent(10)
|
.column(DiffColumn::Duration, "Duration", |c| c.width_percent(25))
|
||||||
})
|
.default_column(DiffColumn::Height);
|
||||||
.column(DiffColumn::Time, "Block Time", |c| c.width_percent(25))
|
|
||||||
.column(DiffColumn::Duration, "Duration", |c| c.width_percent(25));
|
|
||||||
|
|
||||||
let mining_difficulty_view = LinearLayout::new(Orientation::Vertical)
|
let mining_difficulty_view = LinearLayout::new(Orientation::Vertical)
|
||||||
.child(diff_status_view)
|
.child(diff_status_view)
|
||||||
|
@ -333,22 +321,19 @@ impl TUIStatusListener for TUIMiningView {
|
||||||
let _ = c.call_on_name(
|
let _ = c.call_on_name(
|
||||||
TABLE_MINING_DIFF_STATUS,
|
TABLE_MINING_DIFF_STATUS,
|
||||||
|t: &mut TableView<DiffBlock, DiffColumn>| {
|
|t: &mut TableView<DiffBlock, DiffColumn>| {
|
||||||
t.set_items_stable(diff_stats);
|
t.set_items(diff_stats);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let stratum_stats = stats.stratum_stats.clone();
|
let stratum_stats = stats.stratum_stats.clone();
|
||||||
let worker_stats = stratum_stats.worker_stats;
|
let worker_stats = stratum_stats.worker_stats;
|
||||||
let stratum_enabled = format!("Mining server enabled: {}", stratum_stats.is_enabled);
|
let stratum_enabled = format!("Mining server enabled: {}", stratum_stats.is_enabled);
|
||||||
let stratum_is_running = format!("Mining server running: {}", stratum_stats.is_running);
|
let stratum_is_running = format!("Mining server running: {}", stratum_stats.is_running);
|
||||||
let stratum_num_workers = format!("Number of workers: {}", stratum_stats.num_workers);
|
let stratum_num_workers = format!("Active workers: {}", stratum_stats.num_workers);
|
||||||
|
let stratum_blocks_found = format!("Blocks Found: {}", stratum_stats.blocks_found);
|
||||||
let stratum_block_height = match stratum_stats.num_workers {
|
let stratum_block_height = match stratum_stats.num_workers {
|
||||||
0 => "Solving Block Height: n/a".to_string(),
|
0 => "Solving Block Height: n/a".to_string(),
|
||||||
_ => format!("Solving Block Height: {}", stratum_stats.block_height),
|
_ => format!("Solving Block Height: {}", stratum_stats.block_height),
|
||||||
};
|
};
|
||||||
let stratum_edge_bits = match stratum_stats.num_workers {
|
|
||||||
0 => "Latest POW submitted: n/a".to_string(),
|
|
||||||
_ => format!("Latest POW submitted: Cuckoo{}", stratum_stats.edge_bits),
|
|
||||||
};
|
|
||||||
let stratum_network_difficulty = match stratum_stats.num_workers {
|
let stratum_network_difficulty = match stratum_stats.num_workers {
|
||||||
0 => "Network Difficulty: n/a".to_string(),
|
0 => "Network Difficulty: n/a".to_string(),
|
||||||
_ => format!(
|
_ => format!(
|
||||||
|
@ -373,12 +358,12 @@ impl TUIStatusListener for TUIMiningView {
|
||||||
c.call_on_name("stratum_num_workers_status", |t: &mut TextView| {
|
c.call_on_name("stratum_num_workers_status", |t: &mut TextView| {
|
||||||
t.set_content(stratum_num_workers);
|
t.set_content(stratum_num_workers);
|
||||||
});
|
});
|
||||||
|
c.call_on_name("stratum_blocks_found_status", |t: &mut TextView| {
|
||||||
|
t.set_content(stratum_blocks_found);
|
||||||
|
});
|
||||||
c.call_on_name("stratum_block_height_status", |t: &mut TextView| {
|
c.call_on_name("stratum_block_height_status", |t: &mut TextView| {
|
||||||
t.set_content(stratum_block_height);
|
t.set_content(stratum_block_height);
|
||||||
});
|
});
|
||||||
c.call_on_name("stratum_edge_bits_status", |t: &mut TextView| {
|
|
||||||
t.set_content(stratum_edge_bits);
|
|
||||||
});
|
|
||||||
c.call_on_name("stratum_network_difficulty_status", |t: &mut TextView| {
|
c.call_on_name("stratum_network_difficulty_status", |t: &mut TextView| {
|
||||||
t.set_content(stratum_network_difficulty);
|
t.set_content(stratum_network_difficulty);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue