Skip to content

Commit

Permalink
chore(cu): add crude dedupe of checkpointWasmMemoryCache
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed May 6, 2024
1 parent 683297a commit 3399da7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions servers/cu/src/domain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ export const createApis = async (ctx) => {
findEvaluations: AoEvaluationClient.findEvaluationsWith({ db: sqlite, logger: readResultsLogger })
})

let checkpointP
const checkpointWasmMemoryCache = fromPromise(async () => {
if (checkpointP) {
ctx.logger('Checkpointing of WASM Memory Cache already in progress. Nooping...')
return checkpointP
}

const pArgs = []
wasmMemoryCache.lru.forEach((value) => pArgs.push(value))

await pMap(
checkpointP = pMap(
pArgs,
(value) => saveCheckpoint({ Memory: value.Memory, ...value.evaluation })
.catch((err) => {
Expand Down Expand Up @@ -268,7 +274,11 @@ export const createApis = async (ctx) => {
*/
stopOnError: false
}
).catch(() => {})
)
.catch(() => {})

await checkpointP
checkpointP = undefined
})

const healthcheck = healthcheckWith({ walletAddress: address })
Expand Down

0 comments on commit 3399da7

Please sign in to comment.