]> zoso.dev Git - libnemo.git/commitdiff
Revert "Initial implementation of precalculated block hash components."
authorChris Duncan <chris@zoso.dev>
Sat, 14 Dec 2024 09:58:02 +0000 (01:58 -0800)
committerChris Duncan <chris@zoso.dev>
Sat, 14 Dec 2024 09:58:02 +0000 (01:58 -0800)
This reverts commit 5c1beff8308bf6273d6fd31e91521e2f0a125a0d.

src/lib/workers/pow.ts

index f567943ff9a9aa76fe407cbca06a51ebd2f9ca9e..21668067fb96e8283d9b7261ec48329ea937dc46 100644 (file)
@@ -82,12 +82,6 @@ export class Pow {
                if (this.gl == null) throw new Error('webgl2_required')
                this.gl.clearColor(0, 0, 0, 1)
 
-               const blockHashArray: number[] = []
-               for (let i = 0; i < 8; i++) {
-                       blockHashArray.push(parseInt(reverseHex.slice(i * 8, (i + 1) * 8), 16))
-               }
-               const blockHashComponents: Uint32Array = new Uint32Array(blockHashArray)
-
                // Vertext Shader
                const vsSource = `#version 300 es
                precision highp float;
@@ -115,8 +109,6 @@ export class Pow {
                uniform uvec4 u_work0;
                // Last 4 bytes remain as generated externally
                uniform uvec4 u_work1;
-               // Precalculated block hash components
-               uniform uint blockHash[8];
 
                // Defined separately from uint v[32] below as the original value is required
                // to calculate the second uint32 of the digest for threshold comparison
@@ -228,14 +220,14 @@ export class Pow {
                        m[1] = (u_work1.r ^ (u_work1.g << 8) ^ (u_work1.b << 16) ^ (u_work1.a << 24));
 
                        // Block hash
-                       m[2] = blockHash[0];
-                       m[3] = blockHash[1];
-                       m[4] = blockHash[2];
-                       m[5] = blockHash[3];
-                       m[6] = blockHash[4];
-                       m[7] = blockHash[5];
-                       m[8] = blockHash[6];
-                       m[9] = blockHash[7];
+                       m[2] = 0x${reverseHex.slice(56, 64)}u;
+                       m[3] = 0x${reverseHex.slice(48, 56)}u;
+                       m[4] = 0x${reverseHex.slice(40, 48)}u;
+                       m[5] = 0x${reverseHex.slice(32, 40)}u;
+                       m[6] = 0x${reverseHex.slice(24, 32)}u;
+                       m[7] = 0x${reverseHex.slice(16, 24)}u;
+                       m[8] = 0x${reverseHex.slice(8, 16)}u;
+                       m[9] = 0x${reverseHex.slice(0, 8)}u;
 
                        // twelve rounds of mixing
                        for(i=0;i<12;i++) {
@@ -319,7 +311,6 @@ export class Pow {
 
                const work0Location = this.gl.getUniformLocation(program, 'u_work0')
                const work1Location = this.gl.getUniformLocation(program, 'u_work1')
-               const blockHashLocation = this.gl.getUniformLocation(program, "blockHash")
 
                // Draw output until success or progressCallback says to stop
                let n = 0
@@ -333,7 +324,6 @@ export class Pow {
 
                        this.gl.uniform4uiv(work0Location, this.work0)
                        this.gl.uniform4uiv(work1Location, this.work1)
-                       this.gl.uniform1uiv(blockHashLocation, blockHashComponents)
 
                        this.gl.clear(this.gl.COLOR_BUFFER_BIT)
                        this.gl.drawArrays(this.gl.TRIANGLES, 0, 6)