From b7ff1e97112f96aff4fc251e17b40f6b9bbfd52e 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:19:57 +0800 Subject: [PATCH] fix: make max_time_range optional and not enabled by default --- src/main.rs | 37 +++++++++++++++++-------------------- src/shader.cl | 10 +++++----- src/utils/args.rs | 12 ++++++------ 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/main.rs b/src/main.rs index c6960ac..c18bc56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,25 +58,22 @@ fn main() -> anyhow::Result<()> { .unwrap_or_else(|| chrono::Utc::now().timestamp()); // Use the user-specified time range instead of dimension * iteration - let max_search_offset = ARGS.max_time_range as i64; - - if ARGS.future_timestamp { - info!( - "Starting search from {} and going forward in time (up to {} seconds)", - chrono::DateTime::from_timestamp(start_timestamp, 0) - .unwrap_or_else(chrono::Utc::now) - .to_rfc3339_opts(chrono::SecondsFormat::Millis, true), - max_search_offset - ); - } else { - info!( - "Starting search from {} and going backward in time (up to {} seconds)", - chrono::DateTime::from_timestamp(start_timestamp, 0) - .unwrap_or_else(chrono::Utc::now) - .to_rfc3339_opts(chrono::SecondsFormat::Millis, true), - max_search_offset - ); - } + info!( + "Starting search from {} and going {} in time{}", + chrono::DateTime::from_timestamp(start_timestamp, 0) + .unwrap_or_else(chrono::Utc::now) + .to_rfc3339_opts(chrono::SecondsFormat::Millis, true), + if ARGS.future_timestamp { + "forward" + } else { + "backward" + }, + if ARGS.max_time_range.is_some() { + format!(" (up to {} seconds)", ARGS.max_time_range.unwrap()) + } else { + "".to_string() + }, + ); if ARGS.output.is_none() { if ARGS.no_secret_key_logging { @@ -275,7 +272,7 @@ fn opencl_thread( .arg(&buffer_hashdata) .arg(&buffer_result) .arg(ARGS.iteration as u64) - .arg(ARGS.max_time_range as u32) + .arg(ARGS.max_time_range.unwrap_or(0)) .build() .unwrap(); diff --git a/src/shader.cl b/src/shader.cl index fd9abde..e929422 100644 --- a/src/shader.cl +++ b/src/shader.cl @@ -11,17 +11,17 @@ __kernel void vanity_sha1(__constant uint *hashdata, __global uint *result, cons uint data[CHUNK * 16]; for (uint i = 0; i < CHUNK * 16; i++) data[i] = hashdata[i]; uint nonce = data[1]; - + uint thread_id = get_global_id(0); - + for (uint i = 0; i < iter; i++) { // Use a simple sequential approach that searches close to base time first // 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 - offset = offset % max_time_range; - + if (max_time_range) offset %= max_time_range; + if (FUTURE_MODE) { // For future mode: increment timestamp within range data[1] = nonce + offset; diff --git a/src/utils/args.rs b/src/utils/args.rs index 2c42a25..236ee5e 100644 --- a/src/utils/args.rs +++ b/src/utils/args.rs @@ -89,11 +89,11 @@ pub struct Args { #[arg(long, verbatim_doc_comment)] pub start_timestamp: Option, - /// Maximum time range to search in seconds (default: 86400000 = 1000 days) - /// future_timestamp=true: search from start_timestamp to (start_timestamp + max_time_range) - /// future_timestamp=false: search from (start_timestamp - max_time_range) to start_timestamp - #[arg(long, default_value_t = 86400000, verbatim_doc_comment)] - pub max_time_range: u64, + /// Maximum time range to search in seconds + /// future_timestamp = true: search from start_timestamp to (start_timestamp + max_time_range) + /// future_timestamp = false: search from (start_timestamp - max_time_range) to start_timestamp + #[arg(long, verbatim_doc_comment)] + pub max_time_range: Option, } impl Default for Args { @@ -114,7 +114,7 @@ impl Default for Args { list_device: false, future_timestamp: false, start_timestamp: None, - max_time_range: 86400000, + max_time_range: None, } } }