mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
accounts/keystore: address review concerns
This commit is contained in:
parent
b77771c1fb
commit
794564046f
2 changed files with 4 additions and 8 deletions
|
|
@ -230,7 +230,6 @@ func (ac *accountCache) close() {
|
||||||
|
|
||||||
// readAccount is a helper-function to read an encrypted keyfile
|
// readAccount is a helper-function to read an encrypted keyfile
|
||||||
func readAccount(path string, buf *bufio.Reader) *accounts.Account {
|
func readAccount(path string, buf *bufio.Reader) *accounts.Account {
|
||||||
|
|
||||||
var key struct {
|
var key struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
@ -254,14 +253,12 @@ func readAccount(path string, buf *bufio.Reader) *accounts.Account {
|
||||||
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkFile can be used when a file notification triggered some kind of change on a file
|
// checkFile can be used when a file notification triggered some kind of change on a file
|
||||||
// in the keystore directory. The method checks what happened (change/delete/remove/nothing) and
|
// in the keystore directory. The method checks what happened (change/delete/remove/nothing) and
|
||||||
// updates the keystore accordingly
|
// updates the keystore accordingly
|
||||||
func (ac *accountCache) checkFile(path string) error {
|
func (ac *accountCache) checkFile(path string) error {
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
created, deleted, updated, err := ac.fileC.checkFile(path)
|
created, deleted, updated, err := ac.fileC.checkFile(path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,12 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
}
|
||||||
|
|
||||||
// newTempDir returns the name of new temporary folder (not created yet)
|
// newTempDir returns the name of new temporary folder (not created yet)
|
||||||
func newTempDir() (string, error) {
|
func newTempDir() (string, error) {
|
||||||
|
|
||||||
// On OSX, there's a problem
|
// On OSX, there's a problem
|
||||||
// https://stackoverflow.com/questions/45122459/docker-mounts-denied-the-paths-are-not-shared-from-os-x-and-are-not-known/45123074#45123074
|
// https://stackoverflow.com/questions/45122459/docker-mounts-denied-the-paths-are-not-shared-from-os-x-and-are-not-known/45123074#45123074
|
||||||
//
|
//
|
||||||
|
|
@ -63,9 +66,6 @@ func newTempDir() (string, error) {
|
||||||
// However, if we start watching that directory, the notify-events will contain the
|
// However, if we start watching that directory, the notify-events will contain the
|
||||||
// canonical paths, and thus e.g. deleted/updated files won't match our existing files.
|
// canonical paths, and thus e.g. deleted/updated files won't match our existing files.
|
||||||
// TLDR; we need to use the canonical path, which we obtain via EvalSymlinks
|
// TLDR; we need to use the canonical path, which we obtain via EvalSymlinks
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
tmpdir, err := filepath.EvalSymlinks(os.TempDir())
|
tmpdir, err := filepath.EvalSymlinks(os.TempDir())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
@ -115,7 +115,6 @@ func TestWatchNewFile(t *testing.T) {
|
||||||
|
|
||||||
func TestWatchNoDir(t *testing.T) {
|
func TestWatchNoDir(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Create ks but not the directory that it watches.
|
// Create ks but not the directory that it watches.
|
||||||
dir, err := newTempDir()
|
dir, err := newTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue