You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, r is only used in the else branch (when coin_type is not None). This makes the call to await self.resolver(name) somewhat unnecessary when coin_type is None.
Proposed improvement
Move:
r=awaitself.resolver(name)
inside the else block so it’s only called when coin_type is not None, i.e.:
Prevent the extra await self.resolver(name) call when it’s not used.
Potentially be more readable, showing that r is only needed for multichain address lookups (coin_type != None).
Questions/Concerns
Does _resolve(name, "addr") internally call self.resolver(name) again, making this change inconsequential?
Are there any side effects (like caching) or known behaviors that rely on await self.resolver(name) being called regardless of coin_type?
Would this refactor break any tests or expectations?
Open Discussion
Is this micro-optimization worth it for code clarity and performance?
Or is it clearer to always call await self.resolver(name) in one place, even if the method doesn’t end up using it in the if branch?
Any feedback or guidance would be appreciated. If this change seems reasonable, I’m happy to open a PR—or if it’s not necessary, feel free to close this issue.
Cute Animal Picture
The text was updated successfully, but these errors were encountered:
Hey @abhinay. This looks like a good change. This is low priority but if you opened a PR we'd be happy to review it! Can you make a similar change in the address function of the ENS (sync) class in the same PR if you do decide to open one?
Hey @abhinay. This looks like a good change. This is low priority but if you opened a PR we'd be happy to review it! Can you make a similar change in the address function of the ENS (sync) class in the same PR if you do decide to open one?
What is the current behavior?
In
async_ens.py
, theaddress
method calls:However,
r
is only used in theelse
branch (whencoin_type is not None
). This makes the call toawait self.resolver(name)
somewhat unnecessary whencoin_type
isNone
.Proposed improvement
Move:
inside the
else
block so it’s only called whencoin_type is not None
, i.e.:This should:
await self.resolver(name)
call when it’s not used.r
is only needed for multichain address lookups (coin_type != None
).Questions/Concerns
_resolve(name, "addr")
internally callself.resolver(name)
again, making this change inconsequential?await self.resolver(name)
being called regardless ofcoin_type
?Open Discussion
await self.resolver(name)
in one place, even if the method doesn’t end up using it in theif
branch?Any feedback or guidance would be appreciated. If this change seems reasonable, I’m happy to open a PR—or if it’s not necessary, feel free to close this issue.
Cute Animal Picture
The text was updated successfully, but these errors were encountered: