forked from CyberMiles/travis
-
Notifications
You must be signed in to change notification settings - Fork 3
/
node.go
56 lines (44 loc) · 1.04 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ethereum
import (
"gopkg.in/urfave/cli.v1"
ethUtils "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/node"
)
// Node is the main object.
type Node struct {
node.Node
}
// New creates a new node.
func New(conf *node.Config) (*Node, error) {
stack, err := node.New(conf)
if err != nil {
return nil, err
}
return &Node{*stack}, nil // nolint: vet
}
// Start starts base node and stop p2p server
func (n *Node) Start() error {
// start p2p server
err := n.Node.Start()
if err != nil {
return err
}
// stop it
n.Node.Server().Stop()
return nil
}
// NewNodeConfig for p2p and network layer
// #unstable
func NewNodeConfig(ctx *cli.Context) *node.Config {
nodeConfig := new(node.Config)
ethUtils.SetNodeConfig(ctx, nodeConfig)
return nodeConfig
}
// NewEthConfig for the ethereum services
// #unstable
func NewEthConfig(ctx *cli.Context, stack *node.Node) *eth.Config {
ethConfig := new(eth.Config)
ethUtils.SetEthConfig(ctx, stack, ethConfig)
return ethConfig
}