-
Notifications
You must be signed in to change notification settings - Fork 20.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/clef: only print first N accounts on startup #26128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
signer/core/cliui.go
Outdated
@@ -245,6 +245,9 @@ func (ui *CommandlineUI) OnApprovedTx(tx ethapi.SignTransactionResult) { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 #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).
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).