mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
mobile: remove enodes type declaration
This commit is contained in:
parent
7599999dcd
commit
ffea2e9151
3 changed files with 12 additions and 50 deletions
|
|
@ -20,8 +20,6 @@
|
||||||
package geth
|
package geth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -60,45 +58,3 @@ func NewEnode(rawurl string) (enode *Enode, _ error) {
|
||||||
}
|
}
|
||||||
return &Enode{node}, nil
|
return &Enode{node}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enodes represents a slice of accounts.
|
|
||||||
type Enodes struct{ nodes []*discv5.Node }
|
|
||||||
|
|
||||||
// NewEnodes creates a slice of uninitialized enodes.
|
|
||||||
func NewEnodes(size int) *Enodes {
|
|
||||||
return &Enodes{
|
|
||||||
nodes: make([]*discv5.Node, size),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewEnodesEmpty creates an empty slice of Enode values.
|
|
||||||
func NewEnodesEmpty() *Enodes {
|
|
||||||
return NewEnodes(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Size returns the number of enodes in the slice.
|
|
||||||
func (e *Enodes) Size() int {
|
|
||||||
return len(e.nodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns the enode at the given index from the slice.
|
|
||||||
func (e *Enodes) Get(index int) (enode *Enode, _ error) {
|
|
||||||
if index < 0 || index >= len(e.nodes) {
|
|
||||||
return nil, errors.New("index out of bounds")
|
|
||||||
}
|
|
||||||
return &Enode{e.nodes[index]}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets the enode at the given index in the slice.
|
|
||||||
func (e *Enodes) Set(index int, enode *Enode) error {
|
|
||||||
if index < 0 || index >= len(e.nodes) {
|
|
||||||
return errors.New("index out of bounds")
|
|
||||||
}
|
|
||||||
e.nodes[index] = enode.node
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append adds a new enode element to the end of the slice.
|
|
||||||
func (e *Enodes) Append(enode *Enode) {
|
|
||||||
e.nodes = append(e.nodes, enode.node)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/les"
|
"github.com/ethereum/go-ethereum/les"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||||
"github.com/ethereum/go-ethereum/p2p/nat"
|
"github.com/ethereum/go-ethereum/p2p/nat"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
||||||
|
|
@ -44,7 +45,7 @@ import (
|
||||||
// complexity.
|
// complexity.
|
||||||
type NodeConfig struct {
|
type NodeConfig struct {
|
||||||
// Bootstrap nodes used to establish connectivity with the rest of the network.
|
// Bootstrap nodes used to establish connectivity with the rest of the network.
|
||||||
BootstrapNodes *Enodes
|
BootstrapNodes []Enode
|
||||||
|
|
||||||
// MaxPeers is the maximum number of peers that can be connected. If this is
|
// MaxPeers is the maximum number of peers that can be connected. If this is
|
||||||
// set to zero, then only the configured static and trusted peers can connect.
|
// set to zero, then only the configured static and trusted peers can connect.
|
||||||
|
|
@ -108,7 +109,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
||||||
if config.MaxPeers == 0 {
|
if config.MaxPeers == 0 {
|
||||||
config.MaxPeers = defaultNodeConfig.MaxPeers
|
config.MaxPeers = defaultNodeConfig.MaxPeers
|
||||||
}
|
}
|
||||||
if config.BootstrapNodes == nil || config.BootstrapNodes.Size() == 0 {
|
if config.BootstrapNodes == nil || len(config.BootstrapNodes) == 0 {
|
||||||
config.BootstrapNodes = defaultNodeConfig.BootstrapNodes
|
config.BootstrapNodes = defaultNodeConfig.BootstrapNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,6 +117,11 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
||||||
debug.StartPProf(config.PprofAddress)
|
debug.StartPProf(config.PprofAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodes := make([]*discv5.Node, 0, len(config.BootstrapNodes))
|
||||||
|
for _, node := range config.BootstrapNodes {
|
||||||
|
nodes = append(nodes, node.node)
|
||||||
|
}
|
||||||
|
|
||||||
// Create the empty networking stack
|
// Create the empty networking stack
|
||||||
nodeConf := &node.Config{
|
nodeConf := &node.Config{
|
||||||
Name: clientIdentifier,
|
Name: clientIdentifier,
|
||||||
|
|
@ -125,7 +131,7 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
||||||
P2P: p2p.Config{
|
P2P: p2p.Config{
|
||||||
NoDiscovery: true,
|
NoDiscovery: true,
|
||||||
DiscoveryV5: true,
|
DiscoveryV5: true,
|
||||||
BootstrapNodesV5: config.BootstrapNodes.nodes,
|
BootstrapNodesV5: nodes,
|
||||||
ListenAddr: ":0",
|
ListenAddr: ":0",
|
||||||
NAT: nat.Any(),
|
NAT: nat.Any(),
|
||||||
MaxPeers: config.MaxPeers,
|
MaxPeers: config.MaxPeers,
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,10 @@ func GoerliGenesis() string {
|
||||||
|
|
||||||
// FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
|
// FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
|
||||||
// by the foundation running the V5 discovery protocol.
|
// by the foundation running the V5 discovery protocol.
|
||||||
func FoundationBootnodes() *Enodes {
|
func FoundationBootnodes() []Enode {
|
||||||
nodes := &Enodes{nodes: make([]*discv5.Node, len(params.DiscoveryV5Bootnodes))}
|
nodes := make([]Enode, len(params.DiscoveryV5Bootnodes))
|
||||||
for i, url := range params.DiscoveryV5Bootnodes {
|
for i, url := range params.DiscoveryV5Bootnodes {
|
||||||
nodes.nodes[i] = discv5.MustParseNode(url)
|
nodes[i].node = discv5.MustParseNode(url)
|
||||||
}
|
}
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue