From: Chris Duncan Date: Thu, 9 Jan 2025 14:59:46 +0000 (-0800) Subject: If reset is called, cpuBuffer is destroyed, so it does not make sense to then unmap... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=2a84fa611f4a26cc631de14f6328b3ef4e890684;p=libnemo.git If reset is called, cpuBuffer is destroyed, so it does not make sense to then unmap it, so do that in the try block. Also try searching again after resetting. --- diff --git a/src/lib/nano-pow/classes/gpu.ts b/src/lib/nano-pow/classes/gpu.ts index c6555ad..cf0f2d9 100644 --- a/src/lib/nano-pow/classes/gpu.ts +++ b/src/lib/nano-pow/classes/gpu.ts @@ -193,11 +193,11 @@ export class NanoPowGpu { await this.#cpuBuffer.mapAsync(GPUMapMode.READ) await this.#device.queue.onSubmittedWorkDone() data = new DataView(this.#cpuBuffer.getMappedRange().slice(0)) + this.#cpuBuffer.unmap() } catch (err) { console.warn(`Error getting data from GPU. ${err}`) this.reset() - } finally { - this.#cpuBuffer.unmap() + return this.search(hash, threshold) } if (data == null) throw new Error(`Failed to get data from buffer.`)