Replay 33 captured BM1366 shares through pool
next-build / build (push) Canceled after 0s

This commit is contained in:
2026-10-15 04:11:00 -06:00
parent a1d8e34390
commit 523ec5fd0b
2 changed files with 34 additions and 25 deletions
+27 -19
View File
@@ -23,13 +23,17 @@ fn failure(message: impl Into<String>) -> io::Error {
fn main() -> Result<(), Box<dyn Error>> {
let mut args = std::env::args().skip(1);
let socket = args
.next()
.ok_or_else(|| failure("usage: simulator_pool_replay_probe HAL_SOCKET POOL_ADDRESS"))?;
let socket = args.next().ok_or_else(|| {
failure("usage: simulator_pool_replay_probe HAL_SOCKET POOL_ADDRESS [SHARES]")
})?;
let address: SocketAddr = args
.next()
.ok_or_else(|| failure("missing pool address"))?
.parse()?;
let expected_accepts: usize = args.next().map_or(Ok(1), |value| value.parse())?;
if !(1..=64).contains(&expected_accepts) {
return Err(failure("SHARES must be between 1 and 64").into());
}
if args.next().is_some() {
return Err(failure("unexpected argument").into());
}
@@ -50,33 +54,37 @@ fn main() -> Result<(), Box<dyn Error>> {
)
.map_err(|error| failure(format!("pool handshake: {error:?}")))?;
miner.start()?;
let deadline = Instant::now() + Duration::from_secs(10);
let mut saw_work = false;
let mut saw_submit = false;
let deadline = Instant::now() + Duration::from_secs(10 + 2 * expected_accepts as u64);
let mut issued = 0;
let mut submitted = 0;
let mut accepted = 0;
while Instant::now() < deadline {
let (event, reports) = pool
.cycle(&mut miner)
.map_err(|error| failure(format!("mining cycle: {error:?}")))?;
if reports
submitted += reports
.iter()
.any(|report| matches!(report, ReportEvent::Submitted(_)))
{
saw_submit = true;
}
.filter(|report| matches!(report, ReportEvent::Submitted(_)))
.count();
match event {
PoolEvent::Work(work) => {
if work.header != CAPTURED_HEADER {
if issued == 0 && work.header != CAPTURED_HEADER {
return Err(failure("pool job differs from real-silicon capture").into());
}
saw_work = true;
}
PoolEvent::ShareAccepted(_) if saw_work && saw_submit => {
miner.stop()?;
println!("BM1366 real captured nonce accepted by strict loopback pool");
return Ok(());
issued += 1;
}
PoolEvent::ShareAccepted(_) => {
return Err(failure("unattributed pool acceptance").into())
if accepted >= submitted || accepted >= issued {
return Err(failure("unattributed pool acceptance").into());
}
accepted += 1;
if accepted == expected_accepts {
miner.stop()?;
println!(
"BM1366 real captured nonce accepted by strict loopback pool ({accepted} shares)"
);
return Ok(());
}
}
PoolEvent::ShareRejected(_) => return Err(failure("pool rejected share").into()),
_ => {}