]> git.codecow.com Git - nano-pow.git/commitdiff
Delay bigint conversion.
authorChris Duncan <chris@codecow.com>
Thu, 9 Jul 2026 03:15:46 +0000 (20:15 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 9 Jul 2026 03:15:46 +0000 (20:15 -0700)
src/lib/generate/webgpu/index.ts

index 0eafc868202620be935ce01e8b34220c754d975b..e4894de25805c4f88227c64075dc42d664a0eaca 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! 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<void> {
        }
 }
 
-async function init (hash: BigUint64Array, difficulty: bigint): Promise<void> {
+async function init (hash: bigint, difficulty: bigint): Promise<void> {
        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