export class Pow {
static SEND_THRESHOLD = '0xfffffff8'
+ static WORKLOAD: number = 256 * 4 // must be a multiple of 256
static async find (hash: string, threshold: string = this.SEND_THRESHOLD): Promise<string> {
return new Promise<string>(resolve => {
* @param threshold Number|String Optional difficulty threshold (default=0xFFFFFFF8 since v21)
*/
- // Both width and height must be multiple of 256, (one byte)
- // but do not need to be the same,
- // matching GPU capabilities is the aim
- static webglWidth = 256 * 2
- static webglHeight = 256 * 2
- static gl = new OffscreenCanvas(this.webglWidth, this.webglHeight).getContext('webgl2')
+ static gl = new OffscreenCanvas(this.WORKLOAD, this.WORKLOAD).getContext('webgl2')
static work0 = new Uint8Array(4)
static work1 = new Uint8Array(4)
static SIGMA82: number[] = [
void main() {
int i;
- uint uv_x = uint(uv_pos.x * ${this.webglWidth - 1}.);
- uint uv_y = uint(uv_pos.y * ${this.webglHeight - 1}.);
+ uint uv_x = uint(uv_pos.x * ${this.WORKLOAD - 1}.);
+ uint uv_y = uint(uv_pos.y * ${this.WORKLOAD - 1}.);
uint x_pos = uv_x % 256u;
uint y_pos = uv_y % 256u;
uint x_index = (uv_x - x_pos) / 256u;