storage[key] = item
}
-export function clear (): void {
+function clear (): void {
removeItem(STORAGE_KEY)
}
-export function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | null {
+function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | null {
const item = getItem(STORAGE_KEY)
if (item == null) return null
const cache: WorkGenerateResponse[] = JSON.parse(item)
return match ?? null
}
-export function remove (hash: bigint): void {
+function remove (hash: bigint): void {
const item = getItem(STORAGE_KEY)
if (item == null) return
const cache = JSON.parse(item) as WorkGenerateResponse[]
setItem(STORAGE_KEY, JSON.stringify(cache))
}
-export function set (result: WorkGenerateResponse): WorkGenerateResponse {
+function set (result: WorkGenerateResponse): WorkGenerateResponse {
const item = getItem(STORAGE_KEY) ?? '[]'
const cache: WorkGenerateResponse[] = JSON.parse(item)
if (cache.push(result) > 1000) cache.shift()