diff options
Diffstat (limited to 'node/config.go')
-rw-r--r-- | node/config.go | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/node/config.go b/node/config.go index be9e21b4f..7a0c1688e 100644 --- a/node/config.go +++ b/node/config.go @@ -135,6 +135,9 @@ type Config struct { // *WARNING* Only set this if the node is running in a trusted network, exposing // private APIs to untrusted users is a major security risk. WSExposeAll bool `toml:",omitempty"` + + // Logger is a custom logger to use with the p2p.Server. + Logger log.Logger } // IPCEndpoint resolves an IPC endpoint based on a configured value, taking into @@ -360,35 +363,43 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node { return nodes } -func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { +// AccountConfig determines the settings for scrypt and keydirectory +func (c *Config) AccountConfig() (int, int, string, error) { scryptN := keystore.StandardScryptN scryptP := keystore.StandardScryptP - if conf.UseLightweightKDF { + if c.UseLightweightKDF { scryptN = keystore.LightScryptN scryptP = keystore.LightScryptP } var ( - keydir string - ephemeral string - err error + keydir string + err error ) switch { - case filepath.IsAbs(conf.KeyStoreDir): - keydir = conf.KeyStoreDir - case conf.DataDir != "": - if conf.KeyStoreDir == "" { - keydir = filepath.Join(conf.DataDir, datadirDefaultKeyStore) + case filepath.IsAbs(c.KeyStoreDir): + keydir = c.KeyStoreDir + case c.DataDir != "": + if c.KeyStoreDir == "" { + keydir = filepath.Join(c.DataDir, datadirDefaultKeyStore) } else { - keydir, err = filepath.Abs(conf.KeyStoreDir) + keydir, err = filepath.Abs(c.KeyStoreDir) } - case conf.KeyStoreDir != "": - keydir, err = filepath.Abs(conf.KeyStoreDir) - default: + case c.KeyStoreDir != "": + keydir, err = filepath.Abs(c.KeyStoreDir) + } + return scryptN, scryptP, keydir, err +} + +func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { + scryptN, scryptP, keydir, err := conf.AccountConfig() + var ephemeral string + if keydir == "" { // There is no datadir. keydir, err = ioutil.TempDir("", "go-ethereum-keystore") ephemeral = keydir } + if err != nil { return nil, "", err } |