|
|
|
@@ -128,6 +128,11 @@ const ID_HDR_SORT_REL_DESC: i32 = 766;
|
|
|
|
|
const ID_FILTER_COL: i32 = 730;
|
|
|
|
|
const ID_FILTER_OP: i32 = 731;
|
|
|
|
|
const TIMER_SCAN: i32 = 1;
|
|
|
|
|
/// The scan/drain timer fires this often (ms). A fast tick drains the scan channel
|
|
|
|
|
/// several times a second so the progress counter climbs smoothly instead of
|
|
|
|
|
/// jumping ~1%/s; the once-per-second scheduler work runs every `TICKS_PER_SEC`.
|
|
|
|
|
const TICK_MS: i32 = 200;
|
|
|
|
|
const TICKS_PER_SEC: u64 = 1000 / TICK_MS as u64;
|
|
|
|
|
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
|
|
|
|
|
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
|
|
|
|
|
const DEFER_TABLE: i32 = 1;
|
|
|
|
@@ -640,6 +645,9 @@ pub struct App {
|
|
|
|
|
// Per-miner scan timeout in seconds (round 14 #2).
|
|
|
|
|
scan_timeout_secs: u64,
|
|
|
|
|
countdown: u64,
|
|
|
|
|
/// Counts fast timer ticks; the once-per-second scheduler runs every
|
|
|
|
|
/// `TICKS_PER_SEC` of these (the drains run every tick for smooth progress).
|
|
|
|
|
tick_accum: u64,
|
|
|
|
|
// selection (replaces the old checkbox column), tracked by IP so it
|
|
|
|
|
// survives table refreshes during a scan.
|
|
|
|
|
selected_ips: HashSet<String>,
|
|
|
|
@@ -983,6 +991,7 @@ pub fn build(frame: Widget) -> App {
|
|
|
|
|
auto_secs: scan::load_auto_secs(),
|
|
|
|
|
scan_timeout_secs: scan::load_scan_timeout(),
|
|
|
|
|
countdown: 0,
|
|
|
|
|
tick_accum: 0,
|
|
|
|
|
selected_ips: HashSet::new(),
|
|
|
|
|
pal,
|
|
|
|
|
kpi_cards,
|
|
|
|
@@ -1057,7 +1066,7 @@ pub fn build(frame: Widget) -> App {
|
|
|
|
|
app.view = p.view.to_view();
|
|
|
|
|
}
|
|
|
|
|
app.rebuild_table();
|
|
|
|
|
Widget::timer(TIMER_SCAN, 1000);
|
|
|
|
|
Widget::timer(TIMER_SCAN, TICK_MS);
|
|
|
|
|
app
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2620,6 +2629,9 @@ impl App {
|
|
|
|
|
pub fn drain_scan(&mut self) {
|
|
|
|
|
let Some(handle) = &self.scan else { return };
|
|
|
|
|
let mut changed = false;
|
|
|
|
|
// Coalesce progress: a fast drain may pull many per-address updates; apply
|
|
|
|
|
// only the latest to the gauge/status once, after the loop.
|
|
|
|
|
let mut latest_progress: Option<(usize, usize, String)> = None;
|
|
|
|
|
loop {
|
|
|
|
|
match handle.rx.try_recv() {
|
|
|
|
|
Ok(ScanMsg::Started { total, targets }) => {
|
|
|
|
@@ -2643,12 +2655,7 @@ impl App {
|
|
|
|
|
}
|
|
|
|
|
Ok(ScanMsg::Progress { done, total, ip }) => {
|
|
|
|
|
self.scan_total = total;
|
|
|
|
|
self.progress.gauge_set_value(done.min(total) as i32);
|
|
|
|
|
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
|
|
|
|
wx_rs::set_status_text(&format!(
|
|
|
|
|
"{done}/{total}{where_} ({} found)",
|
|
|
|
|
self.rows.len()
|
|
|
|
|
));
|
|
|
|
|
latest_progress = Some((done, total, ip));
|
|
|
|
|
}
|
|
|
|
|
Ok(ScanMsg::Row(row)) => {
|
|
|
|
|
// Ignore stray rows outside the current target set.
|
|
|
|
@@ -2692,6 +2699,15 @@ impl App {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Apply the coalesced progress once (only while still scanning -- a Done/
|
|
|
|
|
// Failed in this same drain already finalised the gauge).
|
|
|
|
|
if self.scanning {
|
|
|
|
|
if let Some((done, total, ip)) = latest_progress {
|
|
|
|
|
self.progress.gauge_set_value(done.min(total) as i32);
|
|
|
|
|
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
|
|
|
|
wx_rs::set_status_text(&format!("{done}/{total}{where_} ({} found)", self.rows.len()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if changed {
|
|
|
|
|
self.fill_rows();
|
|
|
|
|
}
|
|
|
|
@@ -2705,6 +2721,13 @@ impl App {
|
|
|
|
|
self.drain_refresh();
|
|
|
|
|
self.drain_access_probe();
|
|
|
|
|
self.drain_restore();
|
|
|
|
|
// The drains above run every fast tick (smooth scan progress); the
|
|
|
|
|
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
|
|
|
|
// per second.
|
|
|
|
|
self.tick_accum = self.tick_accum.wrapping_add(1);
|
|
|
|
|
if self.tick_accum % TICKS_PER_SEC != 0 {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
|
|
|
|
// operation progress lives in the Health column, so operations no longer
|
|
|
|
|
// hold or overwrite this line -- only an active scan does.
|
|
|
|
|