From 55bc233c41b55a7ef3af8e0458e1fac56a0c8f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=E5=B0=8F=E9=80=8F=E6=98=8E=E3=83=BB=E5=AE=B8?= =?UTF-8?q?=E2=9C=A8?= <47057319+TransparentLC@users.noreply.github.com> Date: Tue, 6 Jan 2026 15:47:30 +0800 Subject: [PATCH] fix: break instead of wrap in max_time_range mode --- src/main.rs | 6 +++++- src/shader.cl | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index c18bc56..8b63082 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use std::{ sync::{mpsc::*, LazyLock}, thread, time::Instant, + usize, }; use utils::ARGS; use utils::*; @@ -167,7 +168,10 @@ fn main() -> anyhow::Result<()> { thread::spawn(move || opencl_thread(buffer_result, pro_que, rx_hashdata, tx_result)); - let bench_size = (dimension * iteration) as u64; + let bench_size = std::cmp::min( + (dimension * iteration) as u64, + ARGS.max_time_range.map(|x| x as u64).unwrap_or(u64::MAX), + ); let bar = bars.add(init_progress_bar(estimate)); loop { diff --git a/src/shader.cl b/src/shader.cl index e929422..13759ee 100644 --- a/src/shader.cl +++ b/src/shader.cl @@ -19,8 +19,8 @@ __kernel void vanity_sha1(__constant uint *hashdata, __global uint *result, cons // Each thread gets a small sequential offset uint offset = thread_id + i * get_global_size(0); - // Wrap around within max_time_range to avoid going too far - if (max_time_range) offset %= max_time_range; + // Avoid going too far (within max_time_range) + if (max_time_range && offset > max_time_range) break; if (FUTURE_MODE) { // For future mode: increment timestamp within range