Skip to content

Commit 15dee63

Browse files
jsvisagzliudan
authored andcommitted
accounts/keystore: delete the redundant keystore in filename (ethereum#17930)
* accounts/keystore: reduce file name length * accounts/keystore: reduce code line width
1 parent 0acb8dc commit 15dee63

8 files changed

+17
-4
lines changed

accounts/keystore/account_cache.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ func (ac *accountCache) scanAccounts() error {
265265
case (addr == common.Address{}):
266266
log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
267267
default:
268-
return &accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}}
268+
return &accounts.Account{
269+
Address: addr,
270+
URL: accounts.URL{Scheme: KeyStoreScheme, Path: path},
271+
}
269272
}
270273
return nil
271274
}

accounts/keystore/key.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou
170170
if err != nil {
171171
return nil, accounts.Account{}, err
172172
}
173-
a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))}}
173+
a := accounts.Account{
174+
Address: key.Address,
175+
URL: accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))},
176+
}
174177
if err := ks.StoreKey(a.URL.Path, key, auth); err != nil {
175178
zeroKey(key.PrivateKey)
176179
return nil, a, err
@@ -224,5 +227,6 @@ func toISO8601(t time.Time) string {
224227
} else {
225228
tz = fmt.Sprintf("%03d00", offset/3600)
226229
}
227-
return fmt.Sprintf("%04d-%02d-%02dT%02d-%02d-%02d.%09d%s", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), tz)
230+
return fmt.Sprintf("%04d-%02d-%02dT%02d-%02d-%02d.%09d%s",
231+
t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), tz)
228232
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

accounts/keystore/presale.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accou
3838
return accounts.Account{}, nil, err
3939
}
4040
key.Id = uuid.NewRandom()
41-
a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: keyStore.JoinPath(keyFileName(key.Address))}}
41+
a := accounts.Account{
42+
Address: key.Address,
43+
URL: accounts.URL{
44+
Scheme: KeyStoreScheme,
45+
Path: keyStore.JoinPath(keyFileName(key.Address)),
46+
},
47+
}
4248
err = keyStore.StoreKey(a.URL.Path, key, password)
4349
return a, key, err
4450
}
File renamed without changes.

0 commit comments

Comments
 (0)