Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix: update type for contractManifestCache, tweak logs for in-flight …
Browse files Browse the repository at this point in the history
…requests, and add default evaluation options
  • Loading branch information
dtfiedler committed Sep 19, 2023
1 parent 2f6813a commit 34a2ea1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/api/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
EvaluationOptions,
Warp,
} from 'warp-contracts';
import { EVALUATION_TIMEOUT_MS, allowedContractTypes } from '../constants';
import {
DEFAULT_EVALUATION_OPTIONS,
EVALUATION_TIMEOUT_MS,
allowedContractTypes,
} from '../constants';
import { ContractType } from '../types';
import * as _ from 'lodash';
import { EvaluationTimeoutError } from '../errors';
Expand Down Expand Up @@ -77,7 +81,7 @@ class ContractManifestCacheKey {
// Aggressively cache contract manifests since they're permanent on chain
const contractManifestCache: ReadThroughPromiseCache<
ContractManifestCacheKey,
any
EvaluationManifest
> = new ReadThroughPromiseCache({
cacheParams: {
cacheCapacity: 1000,
Expand Down Expand Up @@ -141,7 +145,7 @@ async function readThroughToContractState(
});
})
.finally(() => {
logger?.debug('Removing cached request from barrier map.', {
logger?.debug('Removing request from in-flight cache.', {
cacheId,
});
// remove the cached request whether it completes or fails
Expand Down Expand Up @@ -173,9 +177,10 @@ export async function getContractState({
}): Promise<EvaluatedContractState> {
try {
// get the contract manifest eval options by default
const { evaluationOptions } = await contractManifestCache.get(
new ContractManifestCacheKey(contractTxId, warp.arweave, logger),
);
const { evaluationOptions = DEFAULT_EVALUATION_OPTIONS } =
await contractManifestCache.get(
new ContractManifestCacheKey(contractTxId, warp.arweave, logger),
);
// Awaiting here so that promise rejection can be caught below, wrapped, and propagated
return await contractStateCache.get(
new ContractStateCacheKey(contractTxId, evaluationOptions, warp, logger),
Expand Down

0 comments on commit 34a2ea1

Please sign in to comment.