mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
node: port to p2p/enode
This change simply replaces discover.Node and discover.NodeID with their new equivalents.
This commit is contained in:
parent
c59ec7c16c
commit
7b009fa0c3
2 changed files with 11 additions and 11 deletions
10
node/api.go
10
node/api.go
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ func (api *PrivateAdminAPI) AddPeer(url string) (bool, error) {
|
||||||
return false, ErrNodeStopped
|
return false, ErrNodeStopped
|
||||||
}
|
}
|
||||||
// Try to add the url as a static peer and return
|
// Try to add the url as a static peer and return
|
||||||
node, err := discover.ParseNode(url)
|
node, err := enode.ParseV4(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("invalid enode: %v", err)
|
return false, fmt.Errorf("invalid enode: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ func (api *PrivateAdminAPI) RemovePeer(url string) (bool, error) {
|
||||||
return false, ErrNodeStopped
|
return false, ErrNodeStopped
|
||||||
}
|
}
|
||||||
// Try to remove the url as a static peer and return
|
// Try to remove the url as a static peer and return
|
||||||
node, err := discover.ParseNode(url)
|
node, err := enode.ParseV4(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("invalid enode: %v", err)
|
return false, fmt.Errorf("invalid enode: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -82,7 +82,7 @@ func (api *PrivateAdminAPI) AddTrustedPeer(url string) (bool, error) {
|
||||||
if server == nil {
|
if server == nil {
|
||||||
return false, ErrNodeStopped
|
return false, ErrNodeStopped
|
||||||
}
|
}
|
||||||
node, err := discover.ParseNode(url)
|
node, err := enode.ParseV4(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("invalid enode: %v", err)
|
return false, fmt.Errorf("invalid enode: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ func (api *PrivateAdminAPI) RemoveTrustedPeer(url string) (bool, error) {
|
||||||
if server == nil {
|
if server == nil {
|
||||||
return false, ErrNodeStopped
|
return false, ErrNodeStopped
|
||||||
}
|
}
|
||||||
node, err := discover.ParseNode(url)
|
node, err := enode.ParseV4(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("invalid enode: %v", err)
|
return false, fmt.Errorf("invalid enode: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discover"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -336,18 +336,18 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StaticNodes returns a list of node enode URLs configured as static nodes.
|
// StaticNodes returns a list of node enode URLs configured as static nodes.
|
||||||
func (c *Config) StaticNodes() []*discover.Node {
|
func (c *Config) StaticNodes() []*enode.Node {
|
||||||
return c.parsePersistentNodes(c.ResolvePath(datadirStaticNodes))
|
return c.parsePersistentNodes(c.ResolvePath(datadirStaticNodes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrustedNodes returns a list of node enode URLs configured as trusted nodes.
|
// TrustedNodes returns a list of node enode URLs configured as trusted nodes.
|
||||||
func (c *Config) TrustedNodes() []*discover.Node {
|
func (c *Config) TrustedNodes() []*enode.Node {
|
||||||
return c.parsePersistentNodes(c.ResolvePath(datadirTrustedNodes))
|
return c.parsePersistentNodes(c.ResolvePath(datadirTrustedNodes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsePersistentNodes parses a list of discovery node URLs loaded from a .json
|
// parsePersistentNodes parses a list of discovery node URLs loaded from a .json
|
||||||
// file from within the data directory.
|
// file from within the data directory.
|
||||||
func (c *Config) parsePersistentNodes(path string) []*discover.Node {
|
func (c *Config) parsePersistentNodes(path string) []*enode.Node {
|
||||||
// Short circuit if no node config is present
|
// Short circuit if no node config is present
|
||||||
if c.DataDir == "" {
|
if c.DataDir == "" {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -362,12 +362,12 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Interpret the list as a discovery node array
|
// Interpret the list as a discovery node array
|
||||||
var nodes []*discover.Node
|
var nodes []*enode.Node
|
||||||
for _, url := range nodelist {
|
for _, url := range nodelist {
|
||||||
if url == "" {
|
if url == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
node, err := discover.ParseNode(url)
|
node, err := enode.ParseV4(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err))
|
log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err))
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue