From bedf6f40aff0dd14bfab533a37c329ddc9a4bdd5 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 20 Nov 2017 17:39:53 +0100 Subject: cmd/geth: make geth account new faster with many keys (#15529) --- node/config.go | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'node/config.go') diff --git a/node/config.go b/node/config.go index be9e21b4f..1ee02d896 100644 --- a/node/config.go +++ b/node/config.go @@ -360,35 +360,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 } -- cgit v1.2.3 From 54aeb8e4c0bb9f0e7a6c67258af67df3b266af3d Mon Sep 17 00:00:00 2001 From: Lewis Marshall Date: Fri, 1 Dec 2017 11:49:04 +0000 Subject: p2p/simulations: various stability fixes (#15198) p2p/simulations: introduce dialBan - Refactor simulations/network connection getters to support avoiding simultaneous dials between two peers If two peers dial simultaneously, the connection will be dropped to help avoid that, we essentially lock the connection object with a timestamp which serves as a ban on dialing for a period of time (dialBanTimeout). - The connection getter InitConn can be wrapped and passed to the nodes via adapters.NodeConfig#Reachable field and then used by the respective services when they initiate connections. This massively stablise the emerging connectivity when running with hundreds of nodes bootstrapping a network. p2p: add Inbound public method to p2p.Peer p2p/simulations: Add server id to logs to support debugging in-memory network simulations when multiple peers are logging. p2p: SetupConn now returns error. The dialer checks the error and only calls resolve if the actual TCP dial fails. --- node/config.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'node/config.go') diff --git a/node/config.go b/node/config.go index 1ee02d896..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 -- cgit v1.2.3