Page MenuHomePhabricator

D6550.diff
No OneTemporary

D6550.diff

diff --git a/lib/utils/ens-cache.js b/lib/utils/ens-cache.js
--- a/lib/utils/ens-cache.js
+++ b/lib/utils/ens-cache.js
@@ -12,13 +12,13 @@
type ENSNameQueryCacheEntry = {
// We normalize ETH addresses to lowercase characters
+normalizedETHAddress: string,
- +cacheInsertionTime: number,
+ +expirationTime: number,
// We normalize ENS names using eth-ens-namehash
+normalizedENSName: ?string | Promise<?string>,
};
type ENSAddressQueryCacheEntry = {
+normalizedENSName: string,
- +cacheInsertionTime: number,
+ +expirationTime: number,
+normalizedETHAddress: ?string | Promise<?string>,
};
@@ -85,7 +85,7 @@
this.nameQueryCache.set(normalizedETHAddress, {
normalizedETHAddress,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedENSName: fetchENSNamePromise,
});
@@ -93,7 +93,7 @@
const normalizedENSName = await fetchENSNamePromise;
this.nameQueryCache.set(normalizedETHAddress, {
normalizedETHAddress,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedENSName,
});
return normalizedENSName;
@@ -108,8 +108,8 @@
return undefined;
}
- const { cacheInsertionTime } = cacheResult;
- if (cacheInsertionTime + cacheTimeout <= Date.now()) {
+ const { expirationTime } = cacheResult;
+ if (expirationTime <= Date.now()) {
this.nameQueryCache.delete(normalizedETHAddress);
return undefined;
}
@@ -152,7 +152,7 @@
this.addressQueryCache.set(normalizedENSName, {
normalizedENSName,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedETHAddress: fetchETHAddressPromise,
});
@@ -160,7 +160,7 @@
const normalizedETHAddress = await fetchETHAddressPromise;
this.addressQueryCache.set(normalizedENSName, {
normalizedENSName,
- cacheInsertionTime: Date.now(),
+ expirationTime: Date.now() + cacheTimeout,
normalizedETHAddress,
});
return normalizedETHAddress;
@@ -178,8 +178,8 @@
return undefined;
}
- const { cacheInsertionTime } = cacheResult;
- if (cacheInsertionTime + cacheTimeout <= Date.now()) {
+ const { expirationTime } = cacheResult;
+ if (expirationTime <= Date.now()) {
this.addressQueryCache.delete(normalizedENSName);
return undefined;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 6:13 AM (19 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2680653
Default Alt Text
D6550.diff (2 KB)

Event Timeline