From: Chris Duncan Date: Fri, 28 Mar 2025 05:53:28 +0000 (-0700) Subject: Reorder typings in generally descending order. X-Git-Tag: v4.0.10~1 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=7f301696986536a5fc62785f4a24e894a0057d3c;p=nano-pow.git Reorder typings in generally descending order. --- diff --git a/src/types.d.ts b/src/types.d.ts index 1f7bcc8..4780ed3 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -7,6 +7,101 @@ declare global { } } +declare const NanoPow: typeof NanoPowGl | typeof NanoPowGpu | null + +/** +* Nano proof-of-work using WebGL 2.0. +*/ +export declare class NanoPowGl { + static [key: string]: (...args: any[]) => any + #private + /** + * Constructs canvas, gets WebGL context, initializes buffers, and compiles + * shaders. + */ + static init (): Promise + /** + * On WebGL context loss, attempts to clear all program variables and then + * reinitialize them by calling `init()`. + */ + static reset (): void + /** + * Finds a nonce that satisfies the Nano proof-of-work requirements. + * + * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts + * @param {NanoPowOptions} options - Options used to configure search execution + */ + static work_generate (hash: string, options?: NanoPowOptions): Promise + /** + * Validates that a nonce satisfies Nano proof-of-work requirements. + * + * @param {string} work - Hexadecimal proof-of-work value to validate + * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts + * @param {NanoPowOptions} options - Options used to configure search execution + */ + static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise +} + +/** +* Nano proof-of-work using WebGPU. +*/ +export declare class NanoPowGpu { + #private + static [key: string]: (...args: any[]) => any + static init (): Promise + static setup (): void + static reset (): void + /** + * Finds a nonce that satisfies the Nano proof-of-work requirements. + * + * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts + * @param {NanoPowOptions} options - Used to configure search execution + */ + static work_generate (hash: string, options?: NanoPowOptions): Promise + /** + * Validates that a nonce satisfies Nano proof-of-work requirements. + * + * @param {string} work - Hexadecimal proof-of-work value to validate + * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts + * @param {NanoPowOptions} options - Options used to configure search execution + */ + static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise +} + +/** +* Used to configure NanoPow. +* +* @param {boolean} [debug=false] - Enables additional debug logging to the console. Default: false +* @param {number} [effort=0x8] - Multiplier for dispatching work search. Larger values are not necessarily better since they can quickly overwhelm the GPU. Ignored when validating. Default: 0x8 +* @param {bigint|string} [difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000 +*/ +export type NanoPowOptions = { + debug?: boolean + effort?: number + difficulty?: bigint | string +} + +/** +* Used to create WebGL framebuffer objects. +* +* @param {WebGLTexture} - Defines storage size +* @param {WebGLFramebuffer} - Holds texture data +* @param {size} - 2D lengths of texture +*/ +export type FBO = { + texture: WebGLTexture + framebuffer: WebGLFramebuffer + size: { + x: number + y: number + } +} + +export declare const NanoPowGlDownsampleShader: string +export declare const NanoPowGlDrawShader: string +export declare const NanoPowGlVertexShader: string +export declare const NanoPowGpuComputeShader: any + /** * Used by work server for inbound requests to `work_generate`. * @@ -70,98 +165,3 @@ type WorkValidateResponse = { valid_all: '0' | '1' valid_receive: '0' | '1' } - -export declare const NanoPowGlDownsampleShader: string -export declare const NanoPowGlDrawShader: string -export declare const NanoPowGlVertexShader: string -export declare const NanoPowGpuComputeShader: any - -declare const NanoPow: typeof NanoPowGl | typeof NanoPowGpu | null - -/** -* Used to create WebGL framebuffer objects. -* -* @param {WebGLTexture} - Defines storage size -* @param {WebGLFramebuffer} - Holds texture data -* @param {size} - 2D lengths of texture -*/ -export type FBO = { - texture: WebGLTexture - framebuffer: WebGLFramebuffer - size: { - x: number - y: number - } -} - -/** -* Used to configure NanoPow. -* -* @param {boolean} [debug=false] - Enables additional debug logging to the console. Default: false -* @param {number} [effort=0x8] - Multiplier for dispatching work search. Larger values are not necessarily better since they can quickly overwhelm the GPU. Ignored when validating. Default: 0x8 -* @param {bigint|string} [difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000 -*/ -export type NanoPowOptions = { - debug?: boolean - effort?: number - difficulty?: bigint | string -} - -/** -* Nano proof-of-work using WebGL 2.0. -*/ -export declare class NanoPowGl { - static [key: string]: (...args: any[]) => any - #private - /** - * Constructs canvas, gets WebGL context, initializes buffers, and compiles - * shaders. - */ - static init (): Promise - /** - * On WebGL context loss, attempts to clear all program variables and then - * reinitialize them by calling `init()`. - */ - static reset (): void - /** - * Finds a nonce that satisfies the Nano proof-of-work requirements. - * - * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts - * @param {NanoPowOptions} options - Options used to configure search execution - */ - static work_generate (hash: string, options?: NanoPowOptions): Promise - /** - * Validates that a nonce satisfies Nano proof-of-work requirements. - * - * @param {string} work - Hexadecimal proof-of-work value to validate - * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts - * @param {NanoPowOptions} options - Options used to configure search execution - */ - static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise -} - -/** -* Nano proof-of-work using WebGPU. -*/ -export declare class NanoPowGpu { - #private - static [key: string]: (...args: any[]) => any - static init (): Promise - static setup (): void - static reset (): void - /** - * Finds a nonce that satisfies the Nano proof-of-work requirements. - * - * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts - * @param {NanoPowOptions} options - Used to configure search execution - */ - static work_generate (hash: string, options?: NanoPowOptions): Promise - /** - * Validates that a nonce satisfies Nano proof-of-work requirements. - * - * @param {string} work - Hexadecimal proof-of-work value to validate - * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts - * @param {NanoPowOptions} options - Options used to configure search execution - */ - static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise -}