aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/ethereum/flags.go4
-rw-r--r--cmd/ethereum/main.go3
-rw-r--r--cmd/mist/flags.go4
-rw-r--r--cmd/mist/main.go5
-rw-r--r--cmd/mist/ui_lib.go2
-rw-r--r--cmd/utils/cmd.go4
-rw-r--r--eth/backend.go37
-rw-r--r--p2p/discover/table.go4
-rw-r--r--p2p/server.go2
9 files changed, 43 insertions, 22 deletions
diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go
index af57c6a67..87fdd2838 100644
--- a/cmd/ethereum/flags.go
+++ b/cmd/ethereum/flags.go
@@ -49,7 +49,7 @@ var (
AddPeer string
MaxPeer int
GenAddr bool
- SeedNode string
+ BootNodes string
SecretFile string
ExportDir string
NonInteractive bool
@@ -101,7 +101,7 @@ func Init() {
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
- flag.StringVar(&SeedNode, "seednode", "poc-8.ethdev.com:30303", "ip:port of seed node to connect to. Set to blank for skip")
+ flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap")
flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)")
flag.BoolVar(&Dial, "dial", true, "dial out connections (on)")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
index faac0bc5d..14e67fe4a 100644
--- a/cmd/ethereum/main.go
+++ b/cmd/ethereum/main.go
@@ -74,6 +74,7 @@ func main() {
KeyRing: KeyRing,
Shh: SHH,
Dial: Dial,
+ BootNodes: BootNodes,
})
if err != nil {
@@ -133,7 +134,7 @@ func main() {
utils.StartWebSockets(ethereum, WsPort)
}
- utils.StartEthereum(ethereum, SeedNode)
+ utils.StartEthereum(ethereum)
if StartJsConsole {
InitJsConsole(ethereum)
diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go
index f042b39b0..3a7d2ac54 100644
--- a/cmd/mist/flags.go
+++ b/cmd/mist/flags.go
@@ -51,7 +51,7 @@ var (
AddPeer string
MaxPeer int
GenAddr bool
- SeedNode string
+ BootNodes string
SecretFile string
ExportDir string
NonInteractive bool
@@ -116,7 +116,7 @@ func Init() {
flag.BoolVar(&StartRpc, "rpc", true, "start rpc server")
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
- flag.StringVar(&SeedNode, "seednode", "poc-8.ethdev.com:30303", "ip:port of seed node to connect to. Set to blank for skip")
+ flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)")
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
diff --git a/cmd/mist/main.go b/cmd/mist/main.go
index 17ab9467a..5bae33088 100644
--- a/cmd/mist/main.go
+++ b/cmd/mist/main.go
@@ -59,8 +59,9 @@ func run() error {
LogLevel: LogLevel,
MaxPeers: MaxPeer,
Port: OutboundPort,
- NATType: PMPGateway,
+ NATType: NatType,
PMPGateway: PMPGateway,
+ BootNodes: BootNodes,
KeyRing: KeyRing,
Dial: true,
})
@@ -82,7 +83,7 @@ func run() error {
utils.RegisterInterrupt(func(os.Signal) {
gui.Stop()
})
- go utils.StartEthereum(ethereum, SeedNode)
+ go utils.StartEthereum(ethereum)
fmt.Println("ETH stack took", time.Since(tstart))
diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go
index dbebd8a6f..ba3ac3b61 100644
--- a/cmd/mist/ui_lib.go
+++ b/cmd/mist/ui_lib.go
@@ -136,7 +136,7 @@ func (ui *UiLib) Muted(content string) {
func (ui *UiLib) Connect(button qml.Object) {
if !ui.connected {
- ui.eth.Start(SeedNode)
+ ui.eth.Start()
ui.connected = true
button.Set("enabled", false)
}
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 2f48bced5..ecb847fc3 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -121,9 +121,9 @@ func exit(err error) {
os.Exit(status)
}
-func StartEthereum(ethereum *eth.Ethereum, SeedNode string) {
+func StartEthereum(ethereum *eth.Ethereum) {
clilogger.Infoln("Starting ", ethereum.Name())
- if err := ethereum.Start(SeedNode); err != nil {
+ if err := ethereum.Start(); err != nil {
exit(err)
}
RegisterInterrupt(func(sig os.Signal) {
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
diff --git a/p2p/discover/table.go b/p2p/discover/table.go
index 6025507eb..1cdd93a78 100644
--- a/p2p/discover/table.go
+++ b/p2p/discover/table.go
@@ -65,12 +65,12 @@ func (tab *Table) Close() {
// to the network if the table is empty. Bootstrap will also attempt to
// fill the table by performing random lookup operations on the
// network.
-func (tab *Table) Bootstrap(nodes []Node) {
+func (tab *Table) Bootstrap(nodes []*Node) {
tab.mutex.Lock()
// TODO: maybe filter nodes with bad fields (nil, etc.) to avoid strange crashes
tab.nursery = make([]*Node, 0, len(nodes))
for _, n := range nodes {
- cpy := n
+ cpy := *n
tab.nursery = append(tab.nursery, &cpy)
}
tab.mutex.Unlock()
diff --git a/p2p/server.go b/p2p/server.go
index bb3101485..3cab61102 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -50,7 +50,7 @@ type Server struct {
// Bootstrap nodes are used to establish connectivity
// with the rest of the network.
- BootstrapNodes []discover.Node
+ BootstrapNodes []*discover.Node
// Protocols should contain the protocols supported
// by the server. Matching protocols are launched for