-
Notifications
You must be signed in to change notification settings - Fork 21.5k
node: drop support for static & trusted node list files #25610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
88faf1a
964f98a
d27f844
954a1ee
f6244e6
a7cc4e6
7568922
f4ae67d
5b00125
7c5b80c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||
|
||||||
| c.warnOnce(w, true, "Ignoring deprecated node list file %s. Please use the TOML config file instead.", path) | |
| log.Error("Ignoring deprecated node list. Please use the TOML config file instead.", "path", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checkLegacyFiles is only called from here:
if node.server.Config.StaticNodes == nil || node.server.Config.TrustedNodes == nil {
node.config.checkLegacyFiles()
}
So I don't see how that could happen multiple times, so you can just skip that whole dance with &c.staticNodesWarning. I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and thus also remove
- staticNodesWarning bool
- trustedNodesWarning bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using c.Logger is good style. All p2p / node code uses the logger passed via config. It's useful in unit tests.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this seems like a micro-customization. Is it that big of a deal if this method always does WARN instead of ERR ?
I can live with the way it is though, just think it'd be cleaner to leave it be
Uh oh!
There was an error while loading. Please reload this page.