//! 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'
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)
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')
}
}
//! 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'
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')
}
}
+++ /dev/null
-//! 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')
-}