From 2a84fa611f4a26cc631de14f6328b3ef4e890684 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 9 Jan 2025 06:59:46 -0800 Subject: [PATCH] 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. --- src/lib/nano-pow/classes/gpu.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.`) -- 2.34.1