Skip to content

Commit

Permalink
Fix iterating symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Sep 20, 2023
1 parent 7e8d0b9 commit aa92cdc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
6 changes: 4 additions & 2 deletions engine/paima-funnel/src/funnels/FunnelCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export class FunnelCacheManager {
public cacheEntries: CacheMapType = {};

public clear(): void {
for (const entry of Object.values<FunnelCacheEntry>(this.cacheEntries)) {
entry.clear();
for (const entry of Object.getOwnPropertySymbols(this.cacheEntries) as Array<
keyof CacheMapType
>) {
this.cacheEntries[entry]?.clear();
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions engine/paima-funnel/src/funnels/emulated/funnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion engine/paima-runtime/src/runtime-loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(gameStateMachine.getReadWriteDbConn(), async dbTx => {
// Before processing -- sanity check of block height:
if (!(await blockPreProcess(dbTx, gameStateMachine, chainData.blockNumber, pollingPeriod))) {
Expand Down

0 comments on commit aa92cdc

Please sign in to comment.