diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-11-09 22:35:04 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-11-15 00:00:14 +0800 |
commit | b61f48e5aad9cf897f5655a0db002a3349109c67 (patch) | |
tree | 32b0d7d4a126ee444e1cd563c5d4d8ebadef09ec /mobile | |
parent | de4b39a1a32a61a9683a036b2e27e8df7cd4c9ff (diff) | |
download | go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar.gz go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar.bz2 go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar.lz go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar.xz go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.tar.zst go-tangerine-b61f48e5aad9cf897f5655a0db002a3349109c67.zip |
cmd, mobile, node, p2p: surface the discovery V5 bootnodes
Diffstat (limited to 'mobile')
-rw-r--r-- | mobile/discover.go | 34 | ||||
-rw-r--r-- | mobile/geth.go | 26 |
2 files changed, 25 insertions, 35 deletions
diff --git a/mobile/discover.go b/mobile/discover.go index 9b221a874..bb421fc87 100644 --- a/mobile/discover.go +++ b/mobile/discover.go @@ -23,28 +23,14 @@ import ( "errors" "github.com/ethereum/go-ethereum/cmd/utils" - "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/discv5" ) -// MainnetBootnodes returns the enode URLs of the P2P bootstrap nodes running -// on the main network. -// -// Note, this needs to be a method to prevent gomobile generating a setter for it. -func MainnetBootnodes() *Enodes { - nodes := &Enodes{nodes: make([]*discover.Node, len(utils.MainnetBootnodes))} - for i, node := range utils.MainnetBootnodes { - nodes.nodes[i] = node - } - return nodes -} - -// TestnetBootnodes returns the enode URLs of the P2P bootstrap nodes running -// on the test network. -// -// Note, this needs to be a method to prevent gomobile generating a setter for it. -func TestnetBootnodes() *Enodes { - nodes := &Enodes{nodes: make([]*discover.Node, len(utils.TestnetBootnodes))} - for i, node := range utils.TestnetBootnodes { +// FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated +// by the foundation running the V5 discovery protocol. +func FoundationBootnodes() *Enodes { + nodes := &Enodes{nodes: make([]*discv5.Node, len(utils.DiscoveryV5Bootnodes))} + for i, node := range utils.DiscoveryV5Bootnodes { nodes.nodes[i] = node } return nodes @@ -52,7 +38,7 @@ func TestnetBootnodes() *Enodes { // Enode represents a host on the network. type Enode struct { - node *discover.Node + node *discv5.Node } // NewEnode parses a node designator. @@ -79,7 +65,7 @@ type Enode struct { // // enode://<hex node id>@10.3.58.6:30303?discport=30301 func NewEnode(rawurl string) (*Enode, error) { - node, err := discover.ParseNode(rawurl) + node, err := discv5.ParseNode(rawurl) if err != nil { return nil, err } @@ -87,12 +73,12 @@ func NewEnode(rawurl string) (*Enode, error) { } // Enodes represents a slice of accounts. -type Enodes struct{ nodes []*discover.Node } +type Enodes struct{ nodes []*discv5.Node } // NewEnodes creates a slice of uninitialized enodes. func NewEnodes(size int) *Enodes { return &Enodes{ - nodes: make([]*discover.Node, size), + nodes: make([]*discv5.Node, size), } } diff --git a/mobile/geth.go b/mobile/geth.go index 85ac7fec5..4d1f48ec3 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -78,11 +78,11 @@ type NodeConfig struct { // defaultNodeConfig contains the default node configuration values to use if all // or some fields are missing from the user's specified list. var defaultNodeConfig = &NodeConfig{ - BootstrapNodes: MainnetBootnodes(), + BootstrapNodes: FoundationBootnodes(), MaxPeers: 25, EthereumEnabled: true, EthereumNetworkID: 1, - EthereumChainConfig: MainnetChainConfig, + EthereumChainConfig: MainnetChainConfig(), EthereumDatabaseCache: 16, } @@ -106,17 +106,21 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { if config.MaxPeers == 0 { config.MaxPeers = defaultNodeConfig.MaxPeers } + if config.BootstrapNodes == nil || config.BootstrapNodes.Size() == 0 { + config.BootstrapNodes = defaultNodeConfig.BootstrapNodes + } // Create the empty networking stack nodeConf := &node.Config{ - Name: clientIdentifier, - DataDir: datadir, - KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! - NoDiscovery: true, - DiscoveryV5: true, - BootstrapNodes: config.BootstrapNodes.nodes, - ListenAddr: ":0", - NAT: nat.Any(), - MaxPeers: config.MaxPeers, + Name: clientIdentifier, + DataDir: datadir, + KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! + NoDiscovery: true, + DiscoveryV5: true, + DiscoveryV5Addr: ":0", + BootstrapNodesV5: config.BootstrapNodes.nodes, + ListenAddr: ":0", + NAT: nat.Any(), + MaxPeers: config.MaxPeers, } stack, err := node.New(nodeConf) if err != nil { |