Skip to content

Commit

Permalink
chore: Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
CCristi committed Nov 25, 2024
1 parent 12bc456 commit b5c3191
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/explorerkit-server/src/components/idls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ export async function loadAllIdls(programIds: string[]): Promise<IdlsMap> {
idls.set(programId, cachedIdl && new SolanaFMParser(cachedIdl.idl, programId));
}

if (cachedIdl.staleAt.getTime() < Date.now()) {
if (cachedIdl.expiresAt.getTime() < Date.now()) {
addIdlToRefreshQueue(programId);
}
}

return idls;
}

type MaybeIdl = { type: "MISSING"; staleAt: Date } | { type: "IDL"; idl: IdlItem; staleAt: Date };
type MaybeIdl = { type: "MISSING"; expiresAt: Date } | { type: "IDL"; idl: IdlItem; expiresAt: Date };

const IN_MEMORY_PROGRAM_IDLS: Map<String, IdlItem> = new Map([
[
Expand Down Expand Up @@ -155,15 +155,15 @@ export function initIdlsRefreshBackgroundJob(idlRefreshIntervalMs: number) {
const deserializeIdl = (idl: string): MaybeIdl | null => {
try {
const item = JSON.parse(idl) as MaybeIdl;
item.staleAt = new Date(item.staleAt || 0);
item.expiresAt = new Date(item.expiresAt || 0);

return item;
} catch (e) {
return null;
}
};

const serializeIdl = (idl: IdlItem | null, staleAt: Date): string => {
const maybeIdl: MaybeIdl = idl === null ? { type: "MISSING", staleAt } : { type: "IDL", idl, staleAt };
const serializeIdl = (idl: IdlItem | null, expiresAt: Date): string => {
const maybeIdl: MaybeIdl = idl === null ? { type: "MISSING", expiresAt } : { type: "IDL", idl, expiresAt };
return JSON.stringify(maybeIdl);
};

0 comments on commit b5c3191

Please sign in to comment.