From 88faf1a5a3ab6442558175f7a0fe5b33a5b16796 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 26 Aug 2022 15:21:21 +0200 Subject: [PATCH 01/10] node: dont read persistent node files anymore --- node/config.go | 47 ----------------------------------------------- node/node.go | 6 ------ 2 files changed, 53 deletions(-) diff --git a/node/config.go b/node/config.go index 2047299fb5d..b90698fb3d4 100644 --- a/node/config.go +++ b/node/config.go @@ -29,7 +29,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rpc" ) @@ -194,8 +193,6 @@ type Config struct { // Logger is a custom logger to use with the p2p.Server. Logger log.Logger `toml:",omitempty"` - staticNodesWarning bool - trustedNodesWarning bool oldGethResourceWarning bool // AllowUnprotectedTxs allows non EIP-155 protected transactions to be send over RPC. @@ -394,50 +391,6 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey { return key } -// StaticNodes returns a list of node enode URLs configured as static nodes. -func (c *Config) StaticNodes() []*enode.Node { - return c.parsePersistentNodes(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) -} - -// TrustedNodes returns a list of node enode URLs configured as trusted nodes. -func (c *Config) TrustedNodes() []*enode.Node { - return c.parsePersistentNodes(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) -} - -// parsePersistentNodes parses a list of discovery node URLs loaded from a .json -// file from within the data directory. -func (c *Config) parsePersistentNodes(w *bool, path string) []*enode.Node { - // Short circuit if no node config is present - if c.DataDir == "" { - return nil - } - if _, err := os.Stat(path); err != nil { - return nil - } - c.warnOnce(w, "Found deprecated node list file %s, please use the TOML config file instead.", path) - - // Load the nodes from the config file. - var nodelist []string - if err := common.LoadJSON(path, &nodelist); err != nil { - log.Error(fmt.Sprintf("Can't load node list file: %v", err)) - return nil - } - // Interpret the list as a discovery node array - var nodes []*enode.Node - for _, url := range nodelist { - if url == "" { - continue - } - node, err := enode.Parse(enode.ValidSchemes, url) - if err != nil { - log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err)) - continue - } - nodes = append(nodes, node) - } - return nodes -} - // KeyDirConfig determines the settings for keydirectory func (c *Config) KeyDirConfig() (string, error) { var ( diff --git a/node/node.go b/node/node.go index b60e32f22fd..0c8924839dc 100644 --- a/node/node.go +++ b/node/node.go @@ -133,12 +133,6 @@ func New(conf *Config) (*Node, error) { node.server.Config.PrivateKey = node.config.NodeKey() node.server.Config.Name = node.config.NodeName() node.server.Config.Logger = node.log - if node.server.Config.StaticNodes == nil { - node.server.Config.StaticNodes = node.config.StaticNodes() - } - if node.server.Config.TrustedNodes == nil { - node.server.Config.TrustedNodes = node.config.TrustedNodes() - } if node.server.Config.NodeDatabase == "" { node.server.Config.NodeDatabase = node.config.NodeDB() } From 964f98a868884d0eb73439ef462227ed498445c7 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 26 Aug 2022 18:17:26 +0200 Subject: [PATCH 02/10] minor --- node/config.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/node/config.go b/node/config.go index b90698fb3d4..717b5f8acf9 100644 --- a/node/config.go +++ b/node/config.go @@ -33,12 +33,10 @@ import ( ) const ( - datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key - datadirJWTKey = "jwtsecret" // Path within the datadir to the node's jwt secret - datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore - datadirStaticNodes = "static-nodes.json" // Path within the datadir to the static node list - datadirTrustedNodes = "trusted-nodes.json" // Path within the datadir to the trusted node list - datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos + datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key + datadirJWTKey = "jwtsecret" // Path within the datadir to the node's jwt secret + datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore + datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos ) // Config represents a small collection of configuration values to fine tune the From d27f844acbeee808c4f58946bd1f73c6741318c7 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 31 Aug 2022 13:04:12 +0200 Subject: [PATCH 03/10] Revert "minor" This reverts commit 964f98a868884d0eb73439ef462227ed498445c7. --- node/config.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/node/config.go b/node/config.go index 717b5f8acf9..b90698fb3d4 100644 --- a/node/config.go +++ b/node/config.go @@ -33,10 +33,12 @@ import ( ) const ( - datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key - datadirJWTKey = "jwtsecret" // Path within the datadir to the node's jwt secret - datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore - datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos + datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key + datadirJWTKey = "jwtsecret" // Path within the datadir to the node's jwt secret + datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore + datadirStaticNodes = "static-nodes.json" // Path within the datadir to the static node list + datadirTrustedNodes = "trusted-nodes.json" // Path within the datadir to the trusted node list + datadirNodeDatabase = "nodes" // Path within the datadir to store the node infos ) // Config represents a small collection of configuration values to fine tune the From 954a1eed7938ee9e74c27df4fa5e4b13805d2641 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 31 Aug 2022 13:04:13 +0200 Subject: [PATCH 04/10] Revert "node: dont read persistent node files anymore" This reverts commit 88faf1a5a3ab6442558175f7a0fe5b33a5b16796. --- node/config.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ node/node.go | 6 ++++++ 2 files changed, 53 insertions(+) diff --git a/node/config.go b/node/config.go index b90698fb3d4..2047299fb5d 100644 --- a/node/config.go +++ b/node/config.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rpc" ) @@ -193,6 +194,8 @@ type Config struct { // Logger is a custom logger to use with the p2p.Server. Logger log.Logger `toml:",omitempty"` + staticNodesWarning bool + trustedNodesWarning bool oldGethResourceWarning bool // AllowUnprotectedTxs allows non EIP-155 protected transactions to be send over RPC. @@ -391,6 +394,50 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey { return key } +// StaticNodes returns a list of node enode URLs configured as static nodes. +func (c *Config) StaticNodes() []*enode.Node { + return c.parsePersistentNodes(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) +} + +// TrustedNodes returns a list of node enode URLs configured as trusted nodes. +func (c *Config) TrustedNodes() []*enode.Node { + return c.parsePersistentNodes(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) +} + +// parsePersistentNodes parses a list of discovery node URLs loaded from a .json +// file from within the data directory. +func (c *Config) parsePersistentNodes(w *bool, path string) []*enode.Node { + // Short circuit if no node config is present + if c.DataDir == "" { + return nil + } + if _, err := os.Stat(path); err != nil { + return nil + } + c.warnOnce(w, "Found deprecated node list file %s, please use the TOML config file instead.", path) + + // Load the nodes from the config file. + var nodelist []string + if err := common.LoadJSON(path, &nodelist); err != nil { + log.Error(fmt.Sprintf("Can't load node list file: %v", err)) + return nil + } + // Interpret the list as a discovery node array + var nodes []*enode.Node + for _, url := range nodelist { + if url == "" { + continue + } + node, err := enode.Parse(enode.ValidSchemes, url) + if err != nil { + log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err)) + continue + } + nodes = append(nodes, node) + } + return nodes +} + // KeyDirConfig determines the settings for keydirectory func (c *Config) KeyDirConfig() (string, error) { var ( diff --git a/node/node.go b/node/node.go index 0c8924839dc..b60e32f22fd 100644 --- a/node/node.go +++ b/node/node.go @@ -133,6 +133,12 @@ func New(conf *Config) (*Node, error) { node.server.Config.PrivateKey = node.config.NodeKey() node.server.Config.Name = node.config.NodeName() node.server.Config.Logger = node.log + if node.server.Config.StaticNodes == nil { + node.server.Config.StaticNodes = node.config.StaticNodes() + } + if node.server.Config.TrustedNodes == nil { + node.server.Config.TrustedNodes = node.config.TrustedNodes() + } if node.server.Config.NodeDatabase == "" { node.server.Config.NodeDatabase = node.config.NodeDB() } From f6244e6b3d64fdb2bbaac740d1128e99a44cae96 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 31 Aug 2022 15:02:46 +0200 Subject: [PATCH 05/10] Raise error if legacy node files exist --- node/config.go | 56 +++++++++++++++----------------------------------- node/node.go | 7 ++----- 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/node/config.go b/node/config.go index 2047299fb5d..d639699e35c 100644 --- a/node/config.go +++ b/node/config.go @@ -29,7 +29,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rpc" ) @@ -341,7 +340,7 @@ func (c *Config) ResolvePath(path string) string { } if oldpath != "" && common.FileExist(oldpath) { if warn { - c.warnOnce(&c.oldGethResourceWarning, "Using deprecated resource file %s, please move this file to the 'geth' subdirectory of datadir.", oldpath) + c.warnOnce(&c.oldGethResourceWarning, false, "Using deprecated resource file %s, please move this file to the 'geth' subdirectory of datadir.", oldpath) } return oldpath } @@ -394,48 +393,23 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey { return key } -// StaticNodes returns a list of node enode URLs configured as static nodes. -func (c *Config) StaticNodes() []*enode.Node { - return c.parsePersistentNodes(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) +// CheckLegacyFiles inspects the datadir for signs of legacy static-nodes +// and trusted-nodes files. If they exist it raises an error. +func (c *Config) CheckLegacyFiles() { + c.checkLegacyFile(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) + c.checkLegacyFile(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) } -// TrustedNodes returns a list of node enode URLs configured as trusted nodes. -func (c *Config) TrustedNodes() []*enode.Node { - return c.parsePersistentNodes(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) -} - -// parsePersistentNodes parses a list of discovery node URLs loaded from a .json -// file from within the data directory. -func (c *Config) parsePersistentNodes(w *bool, path string) []*enode.Node { +// checkLegacyFile will only raise an error if a file at the given path exists. +func (c *Config) checkLegacyFile(w *bool, path string) { // Short circuit if no node config is present if c.DataDir == "" { - return nil + return } if _, err := os.Stat(path); err != nil { - return nil - } - c.warnOnce(w, "Found deprecated node list file %s, please use the TOML config file instead.", path) - - // Load the nodes from the config file. - var nodelist []string - if err := common.LoadJSON(path, &nodelist); err != nil { - log.Error(fmt.Sprintf("Can't load node list file: %v", err)) - return nil - } - // Interpret the list as a discovery node array - var nodes []*enode.Node - for _, url := range nodelist { - if url == "" { - continue - } - node, err := enode.Parse(enode.ValidSchemes, url) - if err != nil { - log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err)) - continue - } - nodes = append(nodes, node) + return } - return nodes + c.warnOnce(w, true, "Ignoring deprecated node list file %s. Please use the TOML config file instead.", path) } // KeyDirConfig determines the settings for keydirectory @@ -485,7 +459,7 @@ func getKeyStoreDir(conf *Config) (string, bool, error) { var warnLock sync.Mutex -func (c *Config) warnOnce(w *bool, format string, args ...interface{}) { +func (c *Config) warnOnce(w *bool, err bool, format string, args ...interface{}) { warnLock.Lock() defer warnLock.Unlock() @@ -496,6 +470,10 @@ func (c *Config) warnOnce(w *bool, format string, args ...interface{}) { if l == nil { l = log.Root() } - l.Warn(fmt.Sprintf(format, args...)) + if err { + l.Error(fmt.Sprintf(format, args...)) + } else { + l.Warn(fmt.Sprintf(format, args...)) + } *w = true } diff --git a/node/node.go b/node/node.go index b60e32f22fd..4482005cd7d 100644 --- a/node/node.go +++ b/node/node.go @@ -133,11 +133,8 @@ func New(conf *Config) (*Node, error) { node.server.Config.PrivateKey = node.config.NodeKey() node.server.Config.Name = node.config.NodeName() node.server.Config.Logger = node.log - if node.server.Config.StaticNodes == nil { - node.server.Config.StaticNodes = node.config.StaticNodes() - } - if node.server.Config.TrustedNodes == nil { - node.server.Config.TrustedNodes = node.config.TrustedNodes() + if node.server.Config.StaticNodes == nil || node.server.Config.TrustedNodes == nil { + node.config.CheckLegacyFiles() } if node.server.Config.NodeDatabase == "" { node.server.Config.NodeDatabase = node.config.NodeDB() From a7cc4e6084b8214d77e8b9d9d5d857f926bc0a9f Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 31 Aug 2022 16:18:37 +0200 Subject: [PATCH 06/10] unexport checkLegacyFiles --- node/config.go | 2 +- node/node.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/config.go b/node/config.go index d639699e35c..0624dce3324 100644 --- a/node/config.go +++ b/node/config.go @@ -395,7 +395,7 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey { // CheckLegacyFiles inspects the datadir for signs of legacy static-nodes // and trusted-nodes files. If they exist it raises an error. -func (c *Config) CheckLegacyFiles() { +func (c *Config) checkLegacyFiles() { c.checkLegacyFile(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) c.checkLegacyFile(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) } diff --git a/node/node.go b/node/node.go index 4482005cd7d..fc3f3b251b1 100644 --- a/node/node.go +++ b/node/node.go @@ -134,7 +134,7 @@ func New(conf *Config) (*Node, error) { node.server.Config.Name = node.config.NodeName() node.server.Config.Logger = node.log if node.server.Config.StaticNodes == nil || node.server.Config.TrustedNodes == nil { - node.config.CheckLegacyFiles() + node.config.checkLegacyFiles() } if node.server.Config.NodeDatabase == "" { node.server.Config.NodeDatabase = node.config.NodeDB() From 75689220d12a3a4a7bd627369eb1e404c09076ea Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 28 Sep 2022 10:17:40 +0200 Subject: [PATCH 07/10] node: simplify legacy path check --- node/config.go | 49 ++++++++++++++++++++----------------------------- node/node.go | 4 +--- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/node/config.go b/node/config.go index 0624dce3324..1f7ce012c07 100644 --- a/node/config.go +++ b/node/config.go @@ -193,9 +193,7 @@ type Config struct { // Logger is a custom logger to use with the p2p.Server. Logger log.Logger `toml:",omitempty"` - staticNodesWarning bool - trustedNodesWarning bool - oldGethResourceWarning bool + oldGethResourceWarning sync.Once // AllowUnprotectedTxs allows non EIP-155 protected transactions to be send over RPC. AllowUnprotectedTxs bool `toml:",omitempty"` @@ -340,7 +338,9 @@ func (c *Config) ResolvePath(path string) string { } if oldpath != "" && common.FileExist(oldpath) { if warn { - c.warnOnce(&c.oldGethResourceWarning, false, "Using deprecated resource file %s, please move this file to the 'geth' subdirectory of datadir.", oldpath) + c.oldGethResourceWarning.Do(func() { + log.Warn("Using deprecated resource file, please move this file to the 'geth' subdirectory of datadir.", "file", oldpath) + }) } return oldpath } @@ -396,12 +396,12 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey { // CheckLegacyFiles inspects the datadir for signs of legacy static-nodes // and trusted-nodes files. If they exist it raises an error. func (c *Config) checkLegacyFiles() { - c.checkLegacyFile(&c.staticNodesWarning, c.ResolvePath(datadirStaticNodes)) - c.checkLegacyFile(&c.trustedNodesWarning, c.ResolvePath(datadirTrustedNodes)) + c.checkLegacyFile(c.ResolvePath(datadirStaticNodes)) + c.checkLegacyFile(c.ResolvePath(datadirTrustedNodes)) } // checkLegacyFile will only raise an error if a file at the given path exists. -func (c *Config) checkLegacyFile(w *bool, path string) { +func (c *Config) checkLegacyFile(path string) { // Short circuit if no node config is present if c.DataDir == "" { return @@ -409,7 +409,19 @@ func (c *Config) checkLegacyFile(w *bool, path string) { if _, err := os.Stat(path); err != nil { return } - c.warnOnce(w, true, "Ignoring deprecated node list file %s. Please use the TOML config file instead.", path) + logger := c.Logger + if logger == nil { + logger = log.Root() + } + switch fname := filepath.Base(path); fname { + case "static-nodes.json": + log.Error("The static-nodes.json file is deprecated and ignored. Use P2P.StaticNodes in config.toml instead.") + case "trusted-nodes.json": + log.Error("The trusted-nodes.json file is deprecated and ignored. Use P2P.TruestdNodes in config.toml instead.") + default: + // We shouldn't wind up here, but better print something just in case. + log.Error("Ignoring deprecated file.", "file", path) + } } // KeyDirConfig determines the settings for keydirectory @@ -456,24 +468,3 @@ func getKeyStoreDir(conf *Config) (string, bool, error) { return keydir, isEphemeral, nil } - -var warnLock sync.Mutex - -func (c *Config) warnOnce(w *bool, err bool, format string, args ...interface{}) { - warnLock.Lock() - defer warnLock.Unlock() - - if *w { - return - } - l := c.Logger - if l == nil { - l = log.Root() - } - if err { - l.Error(fmt.Sprintf(format, args...)) - } else { - l.Warn(fmt.Sprintf(format, args...)) - } - *w = true -} diff --git a/node/node.go b/node/node.go index fc3f3b251b1..acfb264fbf5 100644 --- a/node/node.go +++ b/node/node.go @@ -133,9 +133,7 @@ func New(conf *Config) (*Node, error) { node.server.Config.PrivateKey = node.config.NodeKey() node.server.Config.Name = node.config.NodeName() node.server.Config.Logger = node.log - if node.server.Config.StaticNodes == nil || node.server.Config.TrustedNodes == nil { - node.config.checkLegacyFiles() - } + node.config.checkLegacyFiles() if node.server.Config.NodeDatabase == "" { node.server.Config.NodeDatabase = node.config.NodeDB() } From f4ae67d5b0279a9332ff29492121372455c31772 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 5 Oct 2022 14:14:19 +0200 Subject: [PATCH 08/10] node: use the right logger --- node/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/config.go b/node/config.go index 1f7ce012c07..c58dd4b0c1d 100644 --- a/node/config.go +++ b/node/config.go @@ -415,12 +415,12 @@ func (c *Config) checkLegacyFile(path string) { } switch fname := filepath.Base(path); fname { case "static-nodes.json": - log.Error("The static-nodes.json file is deprecated and ignored. Use P2P.StaticNodes in config.toml instead.") + logger.Error("The static-nodes.json file is deprecated and ignored. Use P2P.StaticNodes in config.toml instead.") case "trusted-nodes.json": - log.Error("The trusted-nodes.json file is deprecated and ignored. Use P2P.TruestdNodes in config.toml instead.") + logger.Error("The trusted-nodes.json file is deprecated and ignored. Use P2P.TruestdNodes in config.toml instead.") default: // We shouldn't wind up here, but better print something just in case. - log.Error("Ignoring deprecated file.", "file", path) + logger.Error("Ignoring deprecated file.", "file", path) } } From 5b001258ace53d21f807846eaa1d9a8082764233 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 5 Oct 2022 14:21:08 +0200 Subject: [PATCH 09/10] node: fix typo --- node/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/config.go b/node/config.go index c58dd4b0c1d..59dc1c4f7e2 100644 --- a/node/config.go +++ b/node/config.go @@ -417,7 +417,7 @@ func (c *Config) checkLegacyFile(path string) { case "static-nodes.json": logger.Error("The static-nodes.json file is deprecated and ignored. Use P2P.StaticNodes in config.toml instead.") case "trusted-nodes.json": - logger.Error("The trusted-nodes.json file is deprecated and ignored. Use P2P.TruestdNodes in config.toml instead.") + logger.Error("The trusted-nodes.json file is deprecated and ignored. Use P2P.TrustedNodes in config.toml instead.") default: // We shouldn't wind up here, but better print something just in case. logger.Error("Ignoring deprecated file.", "file", path) From 7c5b80c696842a805a31c20db692ebfeb3ea7f60 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 5 Oct 2022 16:22:27 +0200 Subject: [PATCH 10/10] node: simplify warnings and avoid copying locks --- node/config.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/node/config.go b/node/config.go index 59dc1c4f7e2..a54432286d5 100644 --- a/node/config.go +++ b/node/config.go @@ -23,7 +23,6 @@ import ( "path/filepath" "runtime" "strings" - "sync" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -193,7 +192,7 @@ type Config struct { // Logger is a custom logger to use with the p2p.Server. Logger log.Logger `toml:",omitempty"` - oldGethResourceWarning sync.Once + oldGethResourceWarning bool // AllowUnprotectedTxs allows non EIP-155 protected transactions to be send over RPC. AllowUnprotectedTxs bool `toml:",omitempty"` @@ -337,10 +336,9 @@ func (c *Config) ResolvePath(path string) string { oldpath = filepath.Join(c.DataDir, path) } if oldpath != "" && common.FileExist(oldpath) { - if warn { - c.oldGethResourceWarning.Do(func() { - log.Warn("Using deprecated resource file, please move this file to the 'geth' subdirectory of datadir.", "file", oldpath) - }) + if warn && !c.oldGethResourceWarning { + c.oldGethResourceWarning = true + log.Warn("Using deprecated resource file, please move this file to the 'geth' subdirectory of datadir.", "file", oldpath) } return oldpath }