From: Chris Duncan Date: Thu, 9 Jul 2026 03:15:46 +0000 (-0700) Subject: Delay bigint conversion. X-Git-Tag: v5.2.0~11^2 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=e31e3fb38fdb8937190eefc001146b30b79c82fb;p=nano-pow.git Delay bigint conversion. --- 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