return out
}
- static hex_reverse (hex: string): string {
- let out = ''
- for (let i = hex.length; i > 0; i -= 2) {
- out += hex.slice(i - 2, i)
- }
- return out
- }
-
static calculate (hashHex: string, threshold: number | string = '0xFFFFFFF8', callback: (nonce: string | PromiseLike<string>) => any): void {
if (typeof threshold === 'number') threshold = '0x' + threshold.toString(16)
+ if (!/^[A-F-a-f0-9]{64}$/.test(hashHex)) throw new Error(`invalid_hash ${hashHex}`)
+ let reverseHex = ''
+ for (let i = hashHex.length; i > 0; i -= 2) {
+ reverseHex += hashHex.slice(i - 2, i)
+ }
const canvas = new OffscreenCanvas(this.webglWidth, this.webglHeight)
const gl = canvas.getContext('webgl2')
if (!gl)
throw new Error('webgl2_required')
- if (!/^[A-F-a-f0-9]{64}$/.test(hashHex))
- throw new Error(`invalid_hash ${hashHex}`)
-
gl.clearColor(0, 0, 0, 1)
- const reverseHex = this.hex_reverse(hashHex)
// Vertext Shader
const vsSource = `#version 300 es