try {
const { api, debug, difficulty, effort } = await NanoPowConfig(options)
LOG: logger.isEnabled = debug
- const cached = Cache.search(hash, difficulty)
+ const bigintHash = bigintFrom(hash, 'hex')
+ const cached = Cache.search(bigintHash, difficulty)
if (cached) {
LOG: logger.log('found work in cache')
return cached
//! SPDX-License-Identifier: GPL-3.0-or-later
import { WorkGenerateResponse } from "nano-pow"
-import { bigintFrom } from "#utils"
export class Cache {
this.#removeItem('NanoPowCache')
}
- static search (hash: unknown, difficulty: bigint): WorkGenerateResponse | null {
- const bigintHash = bigintFrom(hash, 'hex')
+ static search (hash: bigint, difficulty: bigint): WorkGenerateResponse | null {
const item = this.#getItem('NanoPowCache')
if (item) {
const cache = JSON.parse(item) as WorkGenerateResponse[]
for (const c of cache) {
- if (bigintFrom(c.hash, 'hex') === bigintHash && bigintFrom(c.difficulty, 'hex') >= difficulty) {
+ if (BigInt(`0x${c.hash}`) === hash && BigInt(`0x${c.difficulty}`) >= difficulty) {
return c
}
}
92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D
+92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D
0000000000000000000000000000000000000000000000000000000000000000
badhash
8797585D56B8AEA3A62899C31FC088F9BE849BA8298A88E94F6E3112D4E55D01