浏览代码

accounts/keystore: delete the redundant keystore in filename (#17930)

* accounts/keystore: reduce file name length

* accounts/keystore: reduce code line width
Wenbiao Zheng 7 年之前
父节点
当前提交
32d35c9c08

+ 4 - 1
accounts/keystore/account_cache.go

@@ -265,7 +265,10 @@ func (ac *accountCache) scanAccounts() error {
 		case (addr == common.Address{}):
 		case (addr == common.Address{}):
 			log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
 			log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
 		default:
 		default:
-			return &accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}}
+			return &accounts.Account{
+				Address: addr,
+				URL:     accounts.URL{Scheme: KeyStoreScheme, Path: path},
+			}
 		}
 		}
 		return nil
 		return nil
 	}
 	}

+ 6 - 2
accounts/keystore/key.go

@@ -171,7 +171,10 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou
 	if err != nil {
 	if err != nil {
 		return nil, accounts.Account{}, err
 		return nil, accounts.Account{}, err
 	}
 	}
-	a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))}}
+	a := accounts.Account{
+		Address: key.Address,
+		URL:     accounts.URL{Scheme: KeyStoreScheme, Path: ks.JoinPath(keyFileName(key.Address))},
+	}
 	if err := ks.StoreKey(a.URL.Path, key, auth); err != nil {
 	if err := ks.StoreKey(a.URL.Path, key, auth); err != nil {
 		zeroKey(key.PrivateKey)
 		zeroKey(key.PrivateKey)
 		return nil, a, err
 		return nil, a, err
@@ -224,5 +227,6 @@ func toISO8601(t time.Time) string {
 	} else {
 	} else {
 		tz = fmt.Sprintf("%03d00", offset/3600)
 		tz = fmt.Sprintf("%03d00", offset/3600)
 	}
 	}
-	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)
+	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)
 }
 }

+ 1 - 0
accounts/keystore/keystore_passphrase.go → accounts/keystore/passphrase.go

@@ -233,6 +233,7 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
 		PrivateKey: key,
 		PrivateKey: key,
 	}, nil
 	}, nil
 }
 }
+
 func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error) {
 func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error) {
 	if cryptoJson.Cipher != "aes-128-ctr" {
 	if cryptoJson.Cipher != "aes-128-ctr" {
 		return nil, fmt.Errorf("Cipher not supported: %v", cryptoJson.Cipher)
 		return nil, fmt.Errorf("Cipher not supported: %v", cryptoJson.Cipher)

+ 0 - 0
accounts/keystore/keystore_passphrase_test.go → accounts/keystore/passphrase_test.go


+ 0 - 0
accounts/keystore/keystore_plain.go → accounts/keystore/plain.go


+ 0 - 0
accounts/keystore/keystore_plain_test.go → accounts/keystore/plain_test.go


+ 7 - 1
accounts/keystore/presale.go

@@ -38,7 +38,13 @@ func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accou
 		return accounts.Account{}, nil, err
 		return accounts.Account{}, nil, err
 	}
 	}
 	key.Id = uuid.NewRandom()
 	key.Id = uuid.NewRandom()
-	a := accounts.Account{Address: key.Address, URL: accounts.URL{Scheme: KeyStoreScheme, Path: keyStore.JoinPath(keyFileName(key.Address))}}
+	a := accounts.Account{
+		Address: key.Address,
+		URL: accounts.URL{
+			Scheme: KeyStoreScheme,
+			Path:   keyStore.JoinPath(keyFileName(key.Address)),
+		},
+	}
 	err = keyStore.StoreKey(a.URL.Path, key, password)
 	err = keyStore.StoreKey(a.URL.Path, key, password)
 	return a, key, err
 	return a, key, err
 }
 }

+ 0 - 0
accounts/keystore/keystore_wallet.go → accounts/keystore/wallet.go