/
node.go
54 lines (46 loc) · 1.37 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
package rpc
import (
"github.com/artela-network/artela/ethereum/rpc/types"
"github.com/ethereum/go-ethereum/node"
)
// Node Wrapers Ethereum Node
type Node struct {
*node.Node
}
// Node is an implement of NetworkingStack
var _ types.NetworkingStack = (*Node)(nil)
// Node creates a new NetworkingStack instance.
func NewNode(config *node.Config) (types.NetworkingStack, error) {
node, err := node.New(config)
if err != nil {
return nil, err
}
return &Node{
Node: node,
}, nil
}
// ExtRPCEnabled returns whether or not the external RPC service is enabled.
func (n *Node) ExtRPCEnabled() bool {
return n.Node.Config().ExtRPCEnabled()
}
// Start starts the networking stack.
func (n *Node) Start() error {
return n.Node.Start()
}
// DefaultConfig returns the default configuration for the provider.
func DefaultGethNodeConfig() *node.Config {
nodeCfg := node.DefaultConfig
nodeCfg.P2P.NoDiscovery = true
nodeCfg.P2P.MaxPeers = 0
nodeCfg.Name = clientIdentifier
nodeCfg.HTTPModules = append(nodeCfg.HTTPModules, "eth", "web3", "net", "txpool", "debug")
nodeCfg.WSModules = append(nodeCfg.WSModules, "eth")
nodeCfg.HTTPHost = "0.0.0.0"
nodeCfg.WSHost = "0.0.0.0"
nodeCfg.WSOrigins = []string{"*"}
nodeCfg.HTTPCors = []string{"*"}
nodeCfg.HTTPVirtualHosts = []string{"*"}
nodeCfg.GraphQLCors = []string{"*"}
nodeCfg.GraphQLVirtualHosts = []string{"*"}
return &nodeCfg
}