m[8u] = ubo.blockhash[1u].z;
m[9u] = ubo.blockhash[1u].w;
- var i: u32 = 0u;
- while (atomicLoad(&work.found) == 0u) {
- m[0u] = i;
- i = i + 1u;
-
- /**
- * Compression buffer, intialized to 2 instances of the initialization vector
- * The following values have been modified from the BLAKE2B_IV:
- * OUTLEN is constant 8 bytes
- * v[0] ^= 0x01010000u ^ uint(OUTLEN);
- * INLEN is constant 40 bytes: work value (8) + block hash (32)
- * v[24] ^= uint(INLEN);
- * It's always the "last" compression at this INLEN
- * v[28] = ~v[28];
- * v[29] = ~v[29];
- */
- var v = array<u32, 32>(
- 0xF2BDC900u, 0x6A09E667u, 0x84CAA73Bu, 0xBB67AE85u,
- 0xFE94F82Bu, 0x3C6EF372u, 0x5F1D36F1u, 0xA54FF53Au,
- 0xADE682D1u, 0x510E527Fu, 0x2B3E6C1Fu, 0x9B05688Cu,
- 0xFB41BD6Bu, 0x1F83D9ABu, 0x137E2179u, 0x5BE0CD19u,
- 0xF3BCC908u, 0x6A09E667u, 0x84CAA73Bu, 0xBB67AE85u,
- 0xFE94F82Bu, 0x3C6EF372u, 0x5F1D36F1u, 0xA54FF53Au,
- 0xADE682F9u, 0x510E527Fu, 0x2B3E6C1Fu, 0x9B05688Cu,
- 0x04BE4294u, 0xE07C2654u, 0x137E2179u, 0x5BE0CD19u
- );
+
+ /**
+ * Compression buffer, intialized to 2 instances of the initialization vector
+ * The following values have been modified from the BLAKE2B_IV:
+ * OUTLEN is constant 8 bytes
+ * v[0u] ^= 0x01010000u ^ uint(OUTLEN);
+ * INLEN is constant 40 bytes: work value (8) + block hash (32)
+ * v[24u] ^= uint(INLEN);
+ * It's always the "last" compression at this INLEN
+ * v[28u] = ~v[28u];
+ * v[29u] = ~v[29u];
+ */
+ var v = array<u32, 32>(
+ 0xF2BDC900u, 0x6A09E667u, 0x84CAA73Bu, 0xBB67AE85u,
+ 0xFE94F82Bu, 0x3C6EF372u, 0x5F1D36F1u, 0xA54FF53Au,
+ 0xADE682D1u, 0x510E527Fu, 0x2B3E6C1Fu, 0x9B05688Cu,
+ 0xFB41BD6Bu, 0x1F83D9ABu, 0x137E2179u, 0x5BE0CD19u,
+ 0xF3BCC908u, 0x6A09E667u, 0x84CAA73Bu, 0xBB67AE85u,
+ 0xFE94F82Bu, 0x3C6EF372u, 0x5F1D36F1u, 0xA54FF53Au,
+ 0xADE682F9u, 0x510E527Fu, 0x2B3E6C1Fu, 0x9B05688Cu,
+ 0x04BE4294u, 0xE07C2654u, 0x137E2179u, 0x5BE0CD19u
+ );
+
+ for (var j: u32 = 0u; j < 2u; j = j + 1u) {
+ if (atomicLoad(&work.found) != 0u) {
+ return;
+ }
+ m[0u] = j;
// twelve rounds of mixing
for (var i: u32 = 0u; i < 12u; i = i + 1u) {
// Store the result directly into work array
if ((BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold) {
atomicStore(&work.found, 1u);
- work.nonce.x = i;
+ work.nonce.x = j;
work.nonce.y = id;
return;
}
}
+
+ return;
}
`;