]> zoso.dev Git - nano-pow.git/commitdiff
Adjust debug logging.
authorChris Duncan <chris@zoso.dev>
Wed, 12 Mar 2025 21:34:53 +0000 (14:34 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 12 Mar 2025 21:34:53 +0000 (14:34 -0700)
src/classes/gl.ts
src/classes/gpu.ts

index 4f23b6984fa44d5540e0b0e17d18164687eb5591..141add74297cc9e0903db65d9820da398e3085a2 100644 (file)
@@ -354,6 +354,8 @@ export class NanoPowGl {
                        ? this.#cores
                        : options.effort
                this.#debug = !!(options?.debug)
+               if (this.#debug) console.log('NanoPowGl.search()')
+               if (this.#debug) console.log('blockhash', hash)
                if (this.#debug) console.log('search options', JSON.stringify(options))
 
                /** Reset if user specified new level of effort */
@@ -435,6 +437,8 @@ export class NanoPowGl {
                        ? 0xfffffff8
                        : options.threshold
                this.#debug = !!(options?.debug)
+               if (this.#debug) console.log('NanoPowGl.validate()')
+               if (this.#debug) console.log('blockhash', hash)
                if (this.#debug) console.log('validate options', JSON.stringify(options))
 
                if (NanoPowGl.#gl == null) throw new Error('WebGL 2 is required')
index 0d98770cd0e921855cfc56434c471aa4d285b26d..e91d1823ae78fd0025fef61e9ab18adc242b096f 100644 (file)
@@ -234,6 +234,7 @@ export class NanoPowGpu {
                        ? 0x800
                        : options.effort * 0x100
                this.#debug = !!(options?.debug)
+               if (this.#debug) console.log('NanoPowGpu.search()')
                if (this.#debug) console.log('blockhash', hash)
                if (this.#debug) console.log('search options', JSON.stringify(options))
 
@@ -260,11 +261,11 @@ export class NanoPowGpu {
                        if (this.#debug) console.log(`seed: ${seed}`)
                        const data = await this.#dispatch(this.#searchPipeline, seed, hash, threshold, effort)
                        nonce = data.getBigUint64(0, true)
-                       if (this.#debug) console.log('nonce', nonce, nonce.toString(16).padStart(16, '0'))
                        this.#busy = !data.getUint32(8)
                        times.push(performance.now() - start)
                } while (this.#busy)
                if (this.#debug) this.#logAverages(times)
+               if (this.#debug) console.log('nonce', nonce, nonce.toString(16).padStart(16, '0'))
                return nonce.toString(16).padStart(16, '0')
        }
 
@@ -292,6 +293,7 @@ export class NanoPowGpu {
                        ? 0xfffffff8
                        : options.threshold
                this.#debug = !!(options?.debug)
+               if (this.#debug) console.log('NanoPowGpu.validate()')
                if (this.#debug) console.log('blockhash', hash)
                if (this.#debug) console.log('validate options', JSON.stringify(options))
 
@@ -311,9 +313,9 @@ export class NanoPowGpu {
                if (this.#debug) console.log(`work: ${work}`)
                const data = await this.#dispatch(this.#validatePipeline, seed, hash, threshold, 1)
                const nonce = data.getBigUint64(0, true)
-               if (this.#debug) console.log('nonce', nonce, nonce.toString(16).padStart(16, '0'))
                const found = !!data.getUint32(8)
                this.#busy = false
+               if (this.#debug) console.log('nonce', nonce, nonce.toString(16).padStart(16, '0'))
                if (found && work !== nonce.toString(16).padStart(16, '0')) throw new Error(`Nonce (${nonce.toString(16).padStart(16, '0')}) found but does not match work (${work})`)
                return found
        }