From e31e3fb38fdb8937190eefc001146b30b79c82fb Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 8 Jul 2026 20:15:46 -0700 Subject: [PATCH] Delay bigint conversion. --- src/lib/generate/webgpu/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/generate/webgpu/index.ts b/src/lib/generate/webgpu/index.ts index 0eafc86..e4894de 100644 --- a/src/lib/generate/webgpu/index.ts +++ b/src/lib/generate/webgpu/index.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { bigHex, bigToU64, Logger, Queue } from '#utils' +import { Logger, Queue, bigHex, bigToU64 } from '#utils' import { WorkGenerateResponse } from 'nano-pow' import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl' @@ -177,11 +177,11 @@ async function restore (): Promise { } } -async function init (hash: BigUint64Array, difficulty: bigint): Promise { +async function init (hash: bigint, difficulty: bigint): Promise { LOG: logger.log('variables initializing') try { // Save hash data for normal usage and potential recovery efforts - hashData.set(hash) + hashData.set(bigToU64(hash, 4)) // Write data that will not change per dispatch to uniform buffer object // Note: u64 size is 8, but total alignment must be multiple of 16 @@ -294,7 +294,7 @@ export async function generate (hash: bigint, difficulty: bigint, effort: number throw new Error('failed to start') } } - await q.add(init, bigToU64(hash, 4), difficulty) + await q.add(init, hash, difficulty) // Dispatch initial workgroups and set index await dispatch(0, crypto.getRandomValues(seed)[0], effort) let dispatchIndex = 1 -- 2.52.0