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

Commit

Permalink
fix(gql): fix cacheKey construction for gql interactions
Browse files Browse the repository at this point in the history
The same cache key is being set for varying blockheights, causing the read through cache to return incorrect interactions when the blockHeight is changed in a new request before the cache has expired.
  • Loading branch information
dtfiedler committed Dec 13, 2023
1 parent 91aec06 commit 15406fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
LexicographicalInteractionsSorter,
TagsParser,
} from 'warp-contracts';
import logger from '../logger';
import { ReadThroughPromiseCache } from '@ardrive/ardrive-promise-cache';
import winston from 'winston';

Expand Down Expand Up @@ -120,7 +119,7 @@ class ContractInteractionsCacheKey {

toString(): string {
return `${this.contractTxId}-${
this.blockHeight ? `this.blockHeight` : 'null'
this.blockHeight ? this.blockHeight : 'null'
}${this.address ? `-${this.address}` : ''}`;
}

Expand Down Expand Up @@ -176,6 +175,7 @@ export async function readThroughToWalletInteractionsForContract(
contractTxId,
address,
blockHeight: blockHeightFilter,
logger,
} = cacheKey;
logger?.debug('Reading through to wallet interactions for contract...', {
contractTxId,
Expand Down Expand Up @@ -270,7 +270,7 @@ export async function readThroughToWalletInteractionsForContract(
const contractTag = parser.getContractTag(i.node);

if (!inputTag || !contractTag) {
logger.debug('Invalid tags for interaction via GQL, ignoring...', {
logger?.debug('Invalid tags for interaction via GQL, ignoring...', {
contractTxId,
interactionId: i.node.id,
inputTag,
Expand Down

0 comments on commit 15406fc

Please sign in to comment.