Skip to content

Commit

Permalink
node: dont read persistent node files anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
s1na committed Aug 26, 2022
1 parent f03c37b commit 88faf1a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
47 changes: 0 additions & 47 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 (
Expand Down
6 changes: 0 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 88faf1a

Please sign in to comment.