cmd/clef: only print first N accounts on startup#26128
cmd/clef: only print first N accounts on startup#26128holiman merged 5 commits intoethereum:masterfrom jmcook1186:jc-clef4
Conversation
holiman
left a comment
There was a problem hiding this comment.
I mean, the change is ok -- but is it really needed?
Isn't it just as well to just dump out the lot? I don't see the drawback of leaving it as is, tbh.
|
I think this is a good change. Showing the accounts is mostly useful for people new to clef. If someone is using it for a production setup with lots of keys, it would be annoying to get a huge output dump on startup when you're just trying to debug something. |
Co-authored-by: Martin Holst Swende <martin@swende.se>
| func (ui *CommandlineUI) showAccounts() { | ||
| accounts, err := ui.api.ListAccounts(context.Background()) | ||
| var limit int = 20 //max N accounts to print | ||
| var msg string = fmt.Sprintf("\nFirst %d accounts listed (%d more available).\n", limit, len(accounts)-limit) |
There was a problem hiding this comment.
Seems a bit strange that the "you have more than 20 accounts" is the default, which you initialize here. Feels more natural to have the empty-case be the default, var msg string, and further below have the clause
if limit := 20; len(accounts) > limit {
fmt.Fprintf(out, "\nFirst ...
accounts = accounts[:limit]
...You can probably simplify that a bit too, e.g. by just shortening the accounts to be llimit long. And then the code outside of that clause doesn't need to know that a limit even exists
PR ethereum#26082 added account listing to OnSignerStartup but did not consider the case where a user has a large number of accounts which would be annoying to display. This PR updates showAccounts() so that if there are more than 20 accounts available the user sees the first 20 displayed in the console followed by: First 20 accounts listed (N more available). Co-authored-by: Martin Holst Swende <martin@swende.se>
PR ethereum#26082 added account listing to OnSignerStartup but did not consider the case where a user has a large number of accounts which would be annoying to display. This PR updates showAccounts() so that if there are more than 20 accounts available the user sees the first 20 displayed in the console followed by: First 20 accounts listed (N more available). Co-authored-by: Martin Holst Swende <martin@swende.se>
PR #26082 added account listing to
OnSignerStartupbut did not consider the case where a user has a large number of accounts which would be annoying to display.This PR updates
showAccounts()so that if there are more than 20 accounts available the user sees the first 20 displayed in the console followed by:First 20 accounts listed (N more available).For example for a keystore with > 20 accounts the startup info looks as follows:
For <20 accounts the console info is the same as before.
(NB 20 was a pretty arbitrary choice, I just thought it was a manageable number).