From 1c45b756c45fc39ccad28ad102f67c6b1cb66a6d Mon Sep 17 00:00:00 2001 From: Sebastien Guillemot Date: Wed, 20 Sep 2023 21:17:52 +0900 Subject: [PATCH] Fix iterating symbols --- engine/paima-funnel/src/funnels/FunnelCache.ts | 6 ++++-- engine/paima-funnel/src/funnels/emulated/funnel.ts | 8 +------- engine/paima-runtime/src/runtime-loops.ts | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/engine/paima-funnel/src/funnels/FunnelCache.ts b/engine/paima-funnel/src/funnels/FunnelCache.ts index 46bc52b0a..ebcd70176 100644 --- a/engine/paima-funnel/src/funnels/FunnelCache.ts +++ b/engine/paima-funnel/src/funnels/FunnelCache.ts @@ -16,8 +16,10 @@ export class FunnelCacheManager { public cacheEntries: CacheMapType = {}; public clear(): void { - for (const entry of Object.values(this.cacheEntries)) { - entry.clear(); + for (const entry of Object.getOwnPropertySymbols(this.cacheEntries) as Array< + keyof CacheMapType + >) { + this.cacheEntries[entry]?.clear(); } } } diff --git a/engine/paima-funnel/src/funnels/emulated/funnel.ts b/engine/paima-funnel/src/funnels/emulated/funnel.ts index 4184e8f97..eaeafd16c 100644 --- a/engine/paima-funnel/src/funnels/emulated/funnel.ts +++ b/engine/paima-funnel/src/funnels/emulated/funnel.ts @@ -98,10 +98,7 @@ export class EmulatedBlocksFunnel extends BaseFunnel { const latestAvailableBlockNumber = this.sharedData.cacheManager.cacheEntries[ RpcCacheEntry.SYMBOL ]?.getState(ENV.CHAIN_ID); - if ( - latestAvailableBlockNumber == null || - latestAvailableBlockNumber.state === RpcRequestState.NotRequested - ) + if (latestAvailableBlockNumber?.state !== RpcRequestState.HasResult) throw new Error(`latestAvailableBlockNumber missing from cache for ${ENV.CHAIN_ID}`); // check if the chunk we read matches the latest block known by the RPC endpoint @@ -334,9 +331,6 @@ export class EmulatedBlocksFunnel extends BaseFunnel { // we only want to pop off the queue the entries that correspond for the next ChainData // for the rest, we leave them in the queue to be fetched in the next readData call - if (this.processingQueue.length === 0) { - } else if (this.processingQueue[0].timestamp >= nextBlockEndTimestamp) { - } const mergedBlocks: ChainData[] = []; while ( this.processingQueue.length > 0 && diff --git a/engine/paima-runtime/src/runtime-loops.ts b/engine/paima-runtime/src/runtime-loops.ts index b5d0fc05b..9875dea56 100644 --- a/engine/paima-runtime/src/runtime-loops.ts +++ b/engine/paima-runtime/src/runtime-loops.ts @@ -277,7 +277,7 @@ async function processSyncBlockData( exitIfStopped(run); // note: every state machine update is its own SQL transaction - // this is to ensure things like shutting down and taking snapshots properly sees SM updats + // this is to ensure things like shutting down and taking snapshots properly sees SM updates const success = await tx(gameStateMachine.getReadWriteDbConn(), async dbTx => { // Before processing -- sanity check of block height: if (!(await blockPreProcess(dbTx, gameStateMachine, chainData.blockNumber, pollingPeriod))) {