Page MenuHomePhabricator

D6551.diff
No OneTemporary

D6551.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
@@ -3,6 +3,7 @@
import namehash from 'eth-ens-namehash';
const cacheTimeout = 24 * 60 * 60 * 1000; // one day
+const failedQueryCacheTimeout = 5 * 60 * 1000; // five minutes
export type EthersProvider = {
+lookupAddress: (address: string) => Promise<?string>,
@@ -70,7 +71,13 @@
const fetchENSNamePromise = (async () => {
// ethers.js handles checking forward resolution (point 1 above) for us
- const ensName = await this.provider.lookupAddress(normalizedETHAddress);
+ let ensName;
+ try {
+ ensName = await this.provider.lookupAddress(normalizedETHAddress);
+ } catch (e) {
+ console.log(e);
+ return null;
+ }
if (!ensName) {
return undefined;
}
@@ -91,9 +98,11 @@
return (async () => {
const normalizedENSName = await fetchENSNamePromise;
+ const timeout =
+ normalizedENSName === null ? failedQueryCacheTimeout : cacheTimeout;
this.nameQueryCache.set(normalizedETHAddress, {
normalizedETHAddress,
- expirationTime: Date.now() + cacheTimeout,
+ expirationTime: Date.now() + timeout,
normalizedENSName,
});
return normalizedENSName;
@@ -143,7 +152,13 @@
}
const fetchETHAddressPromise = (async () => {
- const ethAddress = await this.provider.resolveName(normalizedENSName);
+ let ethAddress;
+ try {
+ ethAddress = await this.provider.resolveName(normalizedENSName);
+ } catch (e) {
+ console.log(e);
+ return null;
+ }
if (!ethAddress) {
return undefined;
}
@@ -158,9 +173,11 @@
return (async () => {
const normalizedETHAddress = await fetchETHAddressPromise;
+ const timeout =
+ normalizedETHAddress === null ? failedQueryCacheTimeout : cacheTimeout;
this.addressQueryCache.set(normalizedENSName, {
normalizedENSName,
- expirationTime: Date.now() + cacheTimeout,
+ expirationTime: Date.now() + timeout,
normalizedETHAddress,
});
return normalizedETHAddress;

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 2:34 AM (20 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2679862
Default Alt Text
D6551.diff (2 KB)

Event Timeline