Use more deterministic keystore cache path - #5197
Conversation
Performance Report鉁旓笍 no performance regression detected Full benchmark results
|
nflaig
left a comment
There was a problem hiding this comment.
LGTM! This should address the issue noted in #5043 (comment)
| ...args, | ||
| onDecrypt: needle, | ||
| cacheFilePath: `${args.importKeystores[0]}.cache`, | ||
| cacheFilePath: join(accountPaths.cacheDir, "imported_keystores.cache"), |
There was a problem hiding this comment.
highly opinionated (feel free to ignore) but I really don't like just having join here, someone has to hover the function to know it from path library or scroll up to the imports to see where this is coming from
since path uses such general names for it's functions I generally like to do path., to make it more obvious we are joining paths here
| cacheFilePath: join(accountPaths.cacheDir, "imported_keystores.cache"), | |
| cacheFilePath: path.join(accountPaths.cacheDir, "imported_keystores.cache"), |
There was a problem hiding this comment.
We use destructuring convention all over the code, so seems fine to me. In my preference, I always tend to relate a function to standard library function. If I see a function join I will consider it path.join. If we define a user function which joins string, I would declare it as joinStr to avoid confusion with standard library.
There was a problem hiding this comment.
We use destructuring convention all over the code, so seems fine to me.
I would disagree on when an import should be destructured or not. I do think this should not be based on convention in the code but rather on the design of the library, meaning how did the author/s want you to use it.
In the case of most of the native nodejs libraries those are designed to not use destructuring, one indicator of this are the ambiguous names of functions like for example path has things like delimiter, normalize(path) or parse(path). If we just take parse as an example, this could mean anything, parse a URL, a encoded value, something else? If the authors would have written the library to be more destructuring friendly they would have called this function parsePath.
And if you just look at the docs, for any nodejs library it becomes also clear how they want the libraries to be used, e.g. path, crypto, os
If I see a function join I will consider it path.join.
That might be fine for you as you might know all of the nodejs APIs but for a more unexperienced developer it might not. Functions should clearly convey their purpose without having to think or consider anything and if it requires the code to be more verbose to achieve this it is fine to me.
so seems fine to me.
it definitely is fine in this case, especially since the property right before is called cacheFilePath and the variable is called accountPaths.cacheDir is should be clear that we are joining paths here
This is just more general thing how I think native libraries should be used due to their ambiguous names.
There was a problem hiding this comment.
I really like to see path.join over just join too
There was a problem hiding this comment.
As I mentioned in some earlier discussion, if any style/pattern can't be enforced by linting then we should keep it flexible.
I am creating a separate issue to enforce not to use the destructuring for the some module imports e.g. path. Once we have that rule, the same style will be enforced everywhere.
|
馃帀 This PR is included in v1.6.0 馃帀 |
Motivation
Use more deterministic keystore cache.
Description
Create a new cache directory and use the keystore cache stored in there.
Closes #5141
Steps to test or reproduce
Ru all tests.