diff options
author | Felix Lange <fjl@twurst.com> | 2015-02-07 07:38:36 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-02-07 07:52:49 +0800 |
commit | 028775a0863946c1e9ad51fe7b22faa5c59b2605 (patch) | |
tree | bc3962f1ad12e421cd8f67291af7a571d364b1c4 /eth/backend.go | |
parent | 2cf4fed11b01bb99e08b838f7df2b9396f42f758 (diff) | |
download | go-tangerine-028775a0863946c1e9ad51fe7b22faa5c59b2605.tar.gz go-tangerine-028775a0863946c1e9ad51fe7b22faa5c59b2605.tar.zst go-tangerine-028775a0863946c1e9ad51fe7b22faa5c59b2605.zip |
cmd/ethereum, cmd/mist: add flag for discovery bootstrap nodes
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/eth/backend.go b/eth/backend.go index 6cf2069d7..5ad0f83f4 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -2,6 +2,7 @@ package eth import ( "fmt" + "strings" "sync" "github.com/ethereum/go-ethereum/core" @@ -17,6 +18,8 @@ import ( "github.com/ethereum/go-ethereum/whisper" ) +var logger = ethlogger.NewLogger("SERV") + type Config struct { Name string KeyStore string @@ -30,13 +33,28 @@ type Config struct { NATType string PMPGateway string + // This should be a space-separated list of + // discovery node URLs. + BootNodes string + Shh bool Dial bool KeyManager *crypto.KeyManager } -var logger = ethlogger.NewLogger("SERV") +func (cfg *Config) parseBootNodes() []*discover.Node { + var ns []*discover.Node + for _, url := range strings.Split(cfg.BootNodes, " ") { + n, err := discover.ParseNode(url) + if err != nil { + logger.Errorf("Bootstrap URL %s: %v\n", url, err) + continue + } + ns = append(ns, n) + } + return ns +} type Ethereum struct { // Channel for shutting down the ethereum @@ -134,13 +152,14 @@ func New(config *Config) (*Ethereum, error) { return nil, fmt.Errorf("could not generate server key: %v", err) } eth.net = &p2p.Server{ - PrivateKey: netprv, - Name: config.Name, - MaxPeers: config.MaxPeers, - Protocols: protocols, - Blacklist: eth.blacklist, - NAT: nat, - NoDial: !config.Dial, + PrivateKey: netprv, + Name: config.Name, + MaxPeers: config.MaxPeers, + Protocols: protocols, + Blacklist: eth.blacklist, + NAT: nat, + NoDial: !config.Dial, + BootstrapNodes: config.parseBootNodes(), } if len(config.Port) > 0 { eth.net.ListenAddr = ":" + config.Port @@ -214,7 +233,7 @@ func (s *Ethereum) Coinbase() []byte { } // Start the ethereum -func (s *Ethereum) Start(seedNode string) error { +func (s *Ethereum) Start() error { err := s.net.Start() if err != nil { return err |