mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-27 20:29:39 +02:00
[pitboss] phase 07: M6 — Evidence consumers: formatters, ranking, UI
This commit is contained in:
parent
6f8a645077
commit
bfdfcb9d1a
18 changed files with 3208 additions and 46 deletions
|
|
@ -80,6 +80,24 @@ impl OobListener {
|
|||
.map(|h| h.contains(nonce))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Polls until `nonce` is recorded or `timeout` elapses.
|
||||
///
|
||||
/// Returns immediately on hit; polls every 5 ms otherwise.
|
||||
/// Prefer this over a fixed sleep + `was_nonce_hit` at call sites.
|
||||
pub fn wait_for_nonce(&self, nonce: &str, timeout: Duration) -> bool {
|
||||
let deadline = std::time::Instant::now() + timeout;
|
||||
loop {
|
||||
if self.was_nonce_hit(nonce) {
|
||||
return true;
|
||||
}
|
||||
let remaining = deadline.saturating_duration_since(std::time::Instant::now());
|
||||
if remaining.is_zero() {
|
||||
return false;
|
||||
}
|
||||
std::thread::sleep(remaining.min(Duration::from_millis(5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for OobListener {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue