From: Chris Duncan Date: Mon, 25 May 2026 05:33:15 +0000 (-0700) Subject: Export cache as object only. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=20e85282f1bae9859ade288f73f2f9a741078242;p=nano-pow.git Export cache as object only. --- diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 6e86a3f..f40ddb9 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -28,11 +28,11 @@ function setItem (key: string, item: string): void { 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) @@ -40,7 +40,7 @@ export function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | n 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[] @@ -52,7 +52,7 @@ export function remove (hash: bigint): void { 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()