]> git.codecow.com Git - nano-pow.git/commitdiff
Eliminate extraneous class. Create replacement NanoPow exports for API consistency.
authorChris Duncan <chris@codecow.com>
Sun, 5 Apr 2026 07:05:33 +0000 (00:05 -0700)
committerChris Duncan <chris@codecow.com>
Sun, 5 Apr 2026 07:05:33 +0000 (00:05 -0700)
src/index.ts

index c3c583aa28df4729e486b17cf1e9640961291b00..3a95d6f2c75a91d0c356529580299f6c760dd432 100644 (file)
@@ -4,35 +4,35 @@
 import { NanoPowOptions, WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
 import { generate, validate } from './lib'
 
-export class NanoPow {
-       /**
-       * Finds a nonce that satisfies the Nano proof-of-work requirements.
-       *
-       * @param {bigint | string} hash - Hexadecimal hash of previous block, or public key for new accounts
-       * @param {object} [options] - Used to configure execution
-       * @param {string} [options.api] - Specifies how work is generated. Default: best available
-       * @param {boolean} [options.debug=false] - Enables additional debug logging to the console. Default: false
-       * @param {number} [options.effort=0x4] - GPU load when generating work. Larger values are not necessarily better since they can quickly overwhelm the GPU. Default: 0x4
-       * @param {bigint} [options.difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
-       */
-       static async work_generate (hash: bigint | string, options: NanoPowOptions): Promise<WorkGenerateResponse | WorkErrorResponse> {
-               return generate(hash, options)
-       }
+/**
+* Finds a nonce that satisfies the Nano proof-of-work requirements.
+*
+* @param {bigint | string} hash - Hexadecimal hash of previous block, or public key for new accounts
+* @param {object} [options] - Used to configure execution
+* @param {string} [options.api] - Specifies how work is generated. Default: best available
+* @param {boolean} [options.debug=false] - Enables additional debug logging to the console. Default: false
+* @param {number} [options.effort=0x4] - GPU load when generating work. Larger values are not necessarily better since they can quickly overwhelm the GPU. Default: 0x4
+* @param {bigint} [options.difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
+*/
+export async function work_generate (hash: bigint | string, options: NanoPowOptions): Promise<WorkGenerateResponse | WorkErrorResponse> {
+       return generate(hash, options)
+}
 
-       /**
-       * Validates that a nonce satisfies Nano proof-of-work requirements.
-       *
-       * @param {(bigint|string)} work - Value to validate against hash and difficulty
-       * @param {(bigint|string)} hash - Hash of previous block, or public key for new accounts
-       * @param {object} [options] - Used to configure execution
-       * @param {boolean} [options.debug=false] - Enables additional debug logging to the console. Default: false
-       * @param {bigint} [options.difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
-       */
-       static async work_validate (work: bigint | string, hash: bigint | string, options: NanoPowOptions): Promise<WorkValidateResponse | WorkErrorResponse> {
-               return validate(work, hash, options)
-       }
+/**
+* Validates that a nonce satisfies Nano proof-of-work requirements.
+*
+* @param {(bigint|string)} work - Value to validate against hash and difficulty
+* @param {(bigint|string)} hash - Hash of previous block, or public key for new accounts
+* @param {object} [options] - Used to configure execution
+* @param {boolean} [options.debug=false] - Enables additional debug logging to the console. Default: false
+* @param {bigint} [options.difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
+*/
+export async function work_validate (work: bigint | string, hash: bigint | string, options: NanoPowOptions): Promise<WorkValidateResponse | WorkErrorResponse> {
+       return validate(work, hash, options)
 }
 
-export { clearCache, stats } from '#utils'
-export { NanoPow as default }
+export const NanoPow = { work_generate, work_validate }
 
+export default NanoPow
+
+export { clearCache, stats } from '#utils'