]> zoso.dev Git - nano-pow.git/commitdiff
Print server error if it does not launch, typically due to puppeteer issue. Reset...
authorChris Duncan <chris@zoso.dev>
Sun, 13 Apr 2025 04:59:01 +0000 (21:59 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 13 Apr 2025 04:59:01 +0000 (21:59 -0700)
src/bin/cli.ts
src/bin/nano-pow.sh
src/lib/gl/index.ts
src/lib/gpu/index.ts

index a0b8699e38543f9ec7e96bcb55f30995721ac7a7..3355a6f461d6ff8d908d40063eb733d6b21eaec4 100755 (executable)
@@ -45,9 +45,9 @@ If using --validate, results will also include validity properties.
 
   -h, --help                  show this dialog
       --debug                 enable additional logging output
-           --benchmark <value>     generate work for specified number of random hashes
+      --benchmark <value>     generate work for specified number of random hashes
 
-       -b, --batch                 process all data before returning final results as array
+  -b, --batch                 process all data before returning final results as array
   -d, --difficulty <value>    override the minimum difficulty value
   -e, --effort <value>        increase demand on GPU processing
   -v, --validate <value>      check an existing work value instead of searching for one
@@ -145,7 +145,7 @@ const start = performance.now()
 for (const hash of hashes) {
        try {
                body.hash = hash
-               const kill = setTimeout(aborter.abort, 5000)
+               const kill = setTimeout(() => aborter.abort(), 60000)
                const response = await fetch(`http://localhost:${process.env.NANO_POW_PORT}`, {
                        method: 'POST',
                        body: JSON.stringify(body),
index 6229e98f15e997c204b2ed6eaabc117a5b3ef1ab..5fa0d37fd12ffb11925683f679994532b75a4866 100755 (executable)
@@ -11,6 +11,10 @@ mkdir -p "$NANO_POW_LOGS";
 if [ "$1" = '--server' ]; then
        shift;
        node "$SCRIPT_DIR"/server.js > "$NANO_POW_LOGS"/nano-pow-server-$(date -u -Iseconds).log 2>&1 & echo "$!" > "$NANO_POW_HOME"/server.pid;
+       sleep 0.1;
+       if [ "$(ps | grep $(cat $NANO_POW_HOME/server.pid))" = '' ]; then
+               cat $(ls -td "$NANO_POW_LOGS"/* | head -n1);
+       fi;
 else
        node "$SCRIPT_DIR"/cli.js "$@";
 fi;
index 4d638b47db2b3fca46f5191a226b428a43e94e39..c277d7bb50c685b0faf8f7834700ba3e872fa5cb 100644 (file)
@@ -220,6 +220,7 @@ export class NanoPowGl {
                NanoPowGl.#drawProgram = null
                NanoPowGl.#gl = null
                NanoPowGl.#busy = false
+               NanoPowGl.#isInitialized = false
                NanoPowGl.init()
        }
 
@@ -363,7 +364,7 @@ export class NanoPowGl {
                                setTimeout(async (): Promise<void> => {
                                        const result = this.work_generate(hash, options)
                                        resolve(result)
-                               }, 100)
+                               }, 500)
                        })
                }
                if (this.#isInitialized === false) this.init()
@@ -463,7 +464,7 @@ export class NanoPowGl {
                                setTimeout(async (): Promise<void> => {
                                        const result = this.work_validate(work, hash, options)
                                        resolve(result)
-                               }, 100)
+                               }, 500)
                        })
                }
                if (this.#isInitialized === false) this.init()
index 067a1688eacce938b8c10f877eaacb5809be149c..8f484aaa9fdc3dc30e00543403d84b952ac4df96 100644 (file)
@@ -110,6 +110,7 @@ export class NanoPowGpu {
                NanoPowGpu.#gpuBuffer?.destroy()
                NanoPowGpu.#uboBuffer?.destroy()
                NanoPowGpu.#busy = false
+               NanoPowGpu.#isInitialized = false
                NanoPowGpu.init()
        }
 
@@ -207,7 +208,8 @@ export class NanoPowGpu {
                        this.#cpuBuffer.unmap()
                } catch (err) {
                        console.warn(`Error getting data from GPU. ${err}`)
-                       return this.#dispatch(pipeline, seed, hash, difficulty, passes)
+                       this.#cpuBuffer.unmap()
+                       this.reset()
                }
                if (this.#debug) console.log('gpuBuffer data', data)
                if (data == null) throw new Error(`Failed to get data from buffer.`)
@@ -228,7 +230,7 @@ export class NanoPowGpu {
                                setTimeout(async (): Promise<void> => {
                                        const result = this.work_generate(hash, options)
                                        resolve(result)
-                               }, 100)
+                               }, 500)
                        })
                }
                if (this.#isInitialized === false) this.init()
@@ -307,7 +309,7 @@ export class NanoPowGpu {
                                setTimeout(async (): Promise<void> => {
                                        const result = this.work_validate(work, hash, options)
                                        resolve(result)
-                               }, 100)
+                               }, 500)
                        })
                }
                if (this.#isInitialized === false) this.init()