feat: transfers for viewState

This commit is contained in:
ppedziwiatr
2021-09-03 21:15:06 +02:00
committed by Piotr Pędziwiatr
parent 0c3d22b042
commit 96680f8cf6
4 changed files with 76 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ import {
} from '@smartweave/core';
import Arweave from 'arweave';
import { GQLNodeInterface } from '@smartweave/legacy';
import { LoggerFactory } from '@smartweave/logging';
import { Benchmark, LoggerFactory } from '@smartweave/logging';
/**
* An implementation of DefaultStateEvaluator that adds caching capabilities
@@ -42,10 +42,12 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
// if there was anything to cache...
if (sortedInteractionsUpToBlock.length > 0) {
// get latest available cache for the requested block height
const benchmark = Benchmark.measure();
cachedState = (await this.cache.getLessOrEqual(
executionContext.contractDefinition.txId,
requestedBlockHeight
)) as BlockHeightCacheResult<EvalStateResult<State>>;
logger.trace('Retrieving value from cache', benchmark.elapsed());
if (cachedState != null) {
this.cLogger.debug(`Cached state for ${executionContext.contractDefinition.txId}`, {