]> zoso.dev Git - libnemo.git/commitdiff
Throw more specific error during search call. Revert workload again since research...
authorChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 22:31:16 +0000 (14:31 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 6 Jan 2025 22:31:16 +0000 (14:31 -0800)
src/lib/workers/powgpu.ts

index 23e33101252c56a9675c164c79add9700c6d2d27..42decd50c8fea5e6cd6905051f5ff86eb214debe 100644 (file)
@@ -33,9 +33,6 @@ export class PowGpu extends WorkerInterface {
                })
        }
 
-       // Between 8-256 threads per workgroup based on hardware
-       static workload: number = Math.min(256, Math.max(64, 2 ** (navigator.hardwareConcurrency / 2)))
-
        // WebGPU Compute Shader
        static shader = `
                struct UBO {
@@ -171,7 +168,7 @@ export class PowGpu extends WorkerInterface {
                * 8-byte work is split into two 4-byte u32. Low 4 bytes are random u32 from
                * UBO. High 4 bytes are the random value XOR'd with index of each thread.
                */
-               @compute @workgroup_size(${this.workload})
+               @compute @workgroup_size(256)
                fn main(
                        @builtin(workgroup_id) workgroup_id: vec3<u32>,
                        @builtin(local_invocation_id) local_id: vec3<u32>
@@ -474,7 +471,7 @@ export class PowGpu extends WorkerInterface {
        * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
        */
        static async search (hashHex: string, callback: (nonce: string | PromiseLike<string>) => any, threshold: number = 0xfffffff8): Promise<void> {
-               if (!/^[A-Fa-f0-9]{64}$/.test(hashHex)) throw new Error(`Invalid hash ${hashHex}`)
+               if (!/^[A-Fa-f0-9]{64}$/.test(hashHex)) throw new TypeError(`Invalid hash ${hashHex}`)
                if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`)
 
                // Ensure WebGPU is initialized before calculating, up to a max time frame