Skip to content

Commit

Permalink
Added logs for cache
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Apr 14, 2023
1 parent ec1302a commit fd2a30e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ export class EthImpl implements Eth {
const cacheKey = `${constants.CACHE_KEY.ETH_GET_BALANCE}-${account}-${blockNumberOrTag}`;
const cachedBalance = this.cache.get(cacheKey);
if (cachedBalance) {
return cachedBalance;
this.logger.trace(`${requestIdPrefix} returning cached value ${cacheKey}:${JSON.stringify(cachedBalance)}`);
return cachedBalance;
}

let blockNumber = null;
Expand Down Expand Up @@ -660,6 +661,7 @@ export class EthImpl implements Eth {

// save in cache the current balance for the account and blockNumberOrTag
this.cache.set(cacheKey, EthImpl.numberTo0x(weibars), {ttl: EthImpl.ethGetBalanceCacheTtlMs});
this.logger.trace(`${requestIdPrefix} caching ${cacheKey}:${JSON.stringify(cachedBalance)} for ${EthImpl.ethGetBalanceCacheTtlMs} ms`);

return EthImpl.numberTo0x(weibars);
} catch (error: any) {
Expand Down

0 comments on commit fd2a30e

Please sign in to comment.