import { default as NanoPowGlDownsampleShader } from './gl-downsample.frag'
import { default as NanoPowGlDrawShader } from './gl-draw.frag'
import { default as NanoPowGlVertexShader } from './gl-vertex.vert'
-import type { FBO, NanoPowExecution, NanoPowOptions, WorkGenerateRequest, WorkGenerateResponse, WorkValidateRequest, WorkValidateResponse } from '../../types.d.ts'
+import type { FBO, NanoPowExecution, NanoPowOptions, WorkGenerateResponse, WorkValidateResponse } from '#types'
/**
* Nano proof-of-work using WebGL 2.0.
throw new Error('Query reported result but nonce value not found')
}
- /**
- * 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 async search (hash: string, options?: NanoPowOptions): Promise<string> {
- if (options?.threshold != null) {
- options.threshold = BigInt(`0x${options.threshold.toString(16) ?? '0'}00000000`)
- }
- this.#call = {
- method: 'search',
- hash,
- options
- }
- let result
- try {
- result = await this.work_generate(hash, options)
- } finally {
- this.#call = null
- }
- return result.work
- }
-
/**
* Finds a nonce that satisfies the Nano proof-of-work requirements.
*
}
}
- /**
- * 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 async validate (work: string, hash: string, options?: NanoPowOptions): Promise<boolean> {
- if (options?.threshold != null) {
- options.threshold = BigInt(`0x${options.threshold.toString(16) ?? '0'}00000000`)
- }
- this.#call = {
- method: 'search',
- hash,
- options
- }
- let result
- try {
- result = await this.work_validate(work, hash, options)
- } finally {
- this.#call = null
- }
- return (options?.threshold != null)
- ? result.valid === '1'
- : result.valid_all === '1'
- }
-
/**
* Validates that a nonce satisfies Nano proof-of-work requirements.
*