perf: unnecessary call to arweave.networkInfo when block height is request from client #70

This commit is contained in:
ppedziwiatr
2022-01-03 01:46:49 +01:00
committed by Piotr Pędziwiatr
parent 15f9bff17f
commit a91f379e85
12 changed files with 90 additions and 51 deletions

View File

@@ -1,4 +1,5 @@
import {
Benchmark,
BlockHeightKey,
BlockHeightSwCache,
EvaluationOptions,
@@ -26,6 +27,7 @@ export class CacheableContractInteractionsLoader implements InteractionsLoader {
toBlockHeight: number,
evaluationOptions?: EvaluationOptions
): Promise<GQLEdgeInterface[]> {
const benchmark = Benchmark.measure();
this.logger.debug('Loading interactions', {
contractId,
fromBlockHeight,
@@ -73,6 +75,8 @@ export class CacheableContractInteractionsLoader implements InteractionsLoader {
// - that's why "result" variable is not used here
await this.cache.put(new BlockHeightKey(contractId, toBlockHeight), valueToCache);
this.logger.debug(`Interactions loaded in ${benchmark.elapsed()}`);
return result;
}
}