diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-04 18:59:51 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-05-04 18:59:51 +0800 |
commit | 4accc187d5cf6a100d6c10c0e0f35780f52871a0 (patch) | |
tree | a106654ceccede0c8bcd1fb9402c4eec16bbb6e8 /eth/backend.go | |
parent | 2382da4179fa290582523f598e1be78469cdf274 (diff) | |
download | go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar.gz go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar.bz2 go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar.lz go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar.xz go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.tar.zst go-tangerine-4accc187d5cf6a100d6c10c0e0f35780f52871a0.zip |
eth, p2p: add trusted node list beside static list
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/eth/backend.go b/eth/backend.go index 8aecfba5b..983dd8e4f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -41,8 +41,8 @@ var ( discover.MustParseNode("enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303"), } - // Path within <datadir> to search for the static node list - staticNodes = "static-nodes.json" + staticNodes = "static-nodes.json" // Path within <datadir> to search for the static node list + trustedNodes = "trusted-nodes.json" // Path within <datadir> to search for the trusted node list ) type Config struct { @@ -102,23 +102,22 @@ func (cfg *Config) parseBootNodes() []*discover.Node { return ns } -// parseStaticNodes parses a list of discovery node URLs either given literally, -// or loaded from a .json file. -func (cfg *Config) parseStaticNodes() []*discover.Node { - // Short circuit if no static node config is present - path := filepath.Join(cfg.DataDir, staticNodes) +// parseNodes parses a list of discovery node URLs loaded from a .json file. +func (cfg *Config) parseNodes(file string) []*discover.Node { + // Short circuit if no node config is present + path := filepath.Join(cfg.DataDir, file) if _, err := os.Stat(path); err != nil { return nil } - // Load the static nodes from the config file + // Load the nodes from the config file blob, err := ioutil.ReadFile(path) if err != nil { - glog.V(logger.Error).Infof("Failed to access static nodes: %v", err) + glog.V(logger.Error).Infof("Failed to access nodes: %v", err) return nil } nodelist := []string{} if err := json.Unmarshal(blob, &nodelist); err != nil { - glog.V(logger.Error).Infof("Failed to load static nodes: %v", err) + glog.V(logger.Error).Infof("Failed to load nodes: %v", err) return nil } // Interpret the list as a discovery node array @@ -129,7 +128,7 @@ func (cfg *Config) parseStaticNodes() []*discover.Node { } node, err := discover.ParseNode(url) if err != nil { - glog.V(logger.Error).Infof("Static node URL %s: %v\n", url, err) + glog.V(logger.Error).Infof("Node URL %s: %v\n", url, err) continue } nodes = append(nodes, node) @@ -288,7 +287,8 @@ func New(config *Config) (*Ethereum, error) { NAT: config.NAT, NoDial: !config.Dial, BootstrapNodes: config.parseBootNodes(), - StaticNodes: config.parseStaticNodes(), + StaticNodes: config.parseNodes(staticNodes), + TrustedNodes: config.parseNodes(trustedNodes), NodeDatabase: nodeDb, } if len(config.Port) > 0 { |