]> git.codecow.com Git - nano-pow.git/commitdiff
Deprecate final bigint helper functions. next/bytes-all-the-way
authorChris Duncan <chris@codecow.com>
Mon, 25 May 2026 09:13:01 +0000 (02:13 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 25 May 2026 09:13:01 +0000 (02:13 -0700)
src/lib/generate/webgl/index.ts
src/lib/generate/webgpu/index.ts
src/utils/bigint.ts [deleted file]

index a86f2d7c477467b0500ca81dcd6cf95ebf4a4059..af0b6bb48de51761f8f50e0e7d8660741b89befe 100644 (file)
@@ -2,7 +2,7 @@
 //! SPDX-FileContributor: Ben Green <ben@latenightsketches.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later AND MIT
 
-import { BytesToHex, Logger, bigintToHex } from '#utils'
+import { BytesToHex, Logger } from '#utils'
 import { WorkGenerateResponse } from 'nano-pow'
 import { downsampleSource, drawSource, quadSource } from './shaders'
 
@@ -311,7 +311,7 @@ function draw (seed: bigint, drawFbo: FBO, query: WebGLQuery): void {
        if (gl == null) throw new Error('WebGL 2 is required to draw')
        if (drawFbo == null) throw new Error('FBO is required to draw')
        if (query == null) throw new Error('Query is required to draw')
-       LOG: logger.log(bigintToHex(seed, 16))
+       LOG: logger.log(seed.toString(16).padStart(16, '0'))
 
        // Upload work seed buffer
        inputSeedView.setBigUint64(0, seed, true)
@@ -461,7 +461,7 @@ export async function generate (hash: Bytes, difficulty: bigint, effort: number,
 
        return {
                hash: BytesToHex(hash.buffer, 64),
-               work: bigintToHex(result.work, 16),
-               difficulty: bigintToHex(result.difficulty, 16)
+               work: result.work.toString(16).padStart(16, '0'),
+               difficulty: result.difficulty.toString(16).padStart(16, '0')
        }
 }
index 50a5efe7421628b62d8a04b86f42bac5b0a67087..da7a9c23ecf8eb7b287462f781d0e36958fa40e9 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { BytesToHex, Logger, Queue, bigintToHex } from '#utils'
+import { BytesToHex, Logger, Queue } from '#utils'
 import { WorkGenerateResponse } from 'nano-pow'
 import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl'
 
@@ -329,7 +329,7 @@ export async function generate (hash: Bytes, difficulty: bigint, effort: number,
 
        return {
                hash: BytesToHex(hash.buffer, 64),
-               work: bigintToHex(result.work, 16),
-               difficulty: bigintToHex(result.difficulty, 16)
+               work: result.work.toString(16).padStart(16, '0'),
+               difficulty: result.difficulty.toString(16).padStart(16, '0')
        }
 }
diff --git a/src/utils/bigint.ts b/src/utils/bigint.ts
deleted file mode 100644 (file)
index 4bc3a30..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
-//! SPDX-License-Identifier: GPL-3.0-or-later
-
-export function bigintToHex (int: bigint, length: unknown = 0): string {
-       if (typeof length !== 'number') {
-               throw new TypeError('invalid length')
-       }
-       return int.toString(16).padStart(length, '0')
-}