aboutsummaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-28 14:47:41 -0400
committerDeterminant <tederminant@gmail.com>2020-06-28 14:47:41 -0400
commitd235e2c6a5788ec4a6cff15a16f56b38a3876a0d (patch)
tree5f2727f7a50ee5840f889c82776d3a30a88dd59b /node
parent13ebd8bd9468e9d769d598b0ca2afb72ba78cb97 (diff)
...
Diffstat (limited to 'node')
-rw-r--r--node/api.go184
-rw-r--r--node/config.go12
-rw-r--r--node/defaults.go2
-rw-r--r--node/node.go196
-rw-r--r--node/service.go6
5 files changed, 200 insertions, 200 deletions
diff --git a/node/api.go b/node/api.go
index a6348ce..8352020 100644
--- a/node/api.go
+++ b/node/api.go
@@ -19,13 +19,13 @@ package node
import (
"context"
"fmt"
- "strings"
+ //"strings"
+ "github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/common/hexutil"
"github.com/ava-labs/go-ethereum/crypto"
"github.com/ava-labs/go-ethereum/p2p"
"github.com/ava-labs/go-ethereum/p2p/enode"
- "github.com/ava-labs/go-ethereum/rpc"
)
// PrivateAdminAPI is the collection of administrative API methods exposed only
@@ -142,55 +142,55 @@ func (api *PrivateAdminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription,
return rpcSub, nil
}
-// StartRPC starts the HTTP RPC API server.
-func (api *PrivateAdminAPI) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error) {
- api.node.lock.Lock()
- defer api.node.lock.Unlock()
-
- if api.node.httpHandler != nil {
- return false, fmt.Errorf("HTTP RPC already running on %s", api.node.httpEndpoint)
- }
-
- if host == nil {
- h := DefaultHTTPHost
- if api.node.config.HTTPHost != "" {
- h = api.node.config.HTTPHost
- }
- host = &h
- }
- if port == nil {
- port = &api.node.config.HTTPPort
- }
-
- allowedOrigins := api.node.config.HTTPCors
- if cors != nil {
- allowedOrigins = nil
- for _, origin := range strings.Split(*cors, ",") {
- allowedOrigins = append(allowedOrigins, strings.TrimSpace(origin))
- }
- }
-
- allowedVHosts := api.node.config.HTTPVirtualHosts
- if vhosts != nil {
- allowedVHosts = nil
- for _, vhost := range strings.Split(*host, ",") {
- allowedVHosts = append(allowedVHosts, strings.TrimSpace(vhost))
- }
- }
-
- modules := api.node.httpWhitelist
- if apis != nil {
- modules = nil
- for _, m := range strings.Split(*apis, ",") {
- modules = append(modules, strings.TrimSpace(m))
- }
- }
-
- if err := api.node.startHTTP(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, allowedOrigins, allowedVHosts, api.node.config.HTTPTimeouts); err != nil {
- return false, err
- }
- return true, nil
-}
+//// StartRPC starts the HTTP RPC API server.
+//func (api *PrivateAdminAPI) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error) {
+// api.node.lock.Lock()
+// defer api.node.lock.Unlock()
+//
+// if api.node.httpHandler != nil {
+// return false, fmt.Errorf("HTTP RPC already running on %s", api.node.httpEndpoint)
+// }
+//
+// if host == nil {
+// h := DefaultHTTPHost
+// if api.node.config.HTTPHost != "" {
+// h = api.node.config.HTTPHost
+// }
+// host = &h
+// }
+// if port == nil {
+// port = &api.node.config.HTTPPort
+// }
+//
+// allowedOrigins := api.node.config.HTTPCors
+// if cors != nil {
+// allowedOrigins = nil
+// for _, origin := range strings.Split(*cors, ",") {
+// allowedOrigins = append(allowedOrigins, strings.TrimSpace(origin))
+// }
+// }
+//
+// allowedVHosts := api.node.config.HTTPVirtualHosts
+// if vhosts != nil {
+// allowedVHosts = nil
+// for _, vhost := range strings.Split(*host, ",") {
+// allowedVHosts = append(allowedVHosts, strings.TrimSpace(vhost))
+// }
+// }
+//
+// modules := api.node.httpWhitelist
+// if apis != nil {
+// modules = nil
+// for _, m := range strings.Split(*apis, ",") {
+// modules = append(modules, strings.TrimSpace(m))
+// }
+// }
+//
+// if err := api.node.startHTTP(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, allowedOrigins, allowedVHosts, api.node.config.HTTPTimeouts); err != nil {
+// return false, err
+// }
+// return true, nil
+//}
// StopRPC terminates an already running HTTP RPC API endpoint.
func (api *PrivateAdminAPI) StopRPC() (bool, error) {
@@ -204,47 +204,47 @@ func (api *PrivateAdminAPI) StopRPC() (bool, error) {
return true, nil
}
-// StartWS starts the websocket RPC API server.
-func (api *PrivateAdminAPI) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error) {
- api.node.lock.Lock()
- defer api.node.lock.Unlock()
-
- if api.node.wsHandler != nil {
- return false, fmt.Errorf("WebSocket RPC already running on %s", api.node.wsEndpoint)
- }
-
- if host == nil {
- h := DefaultWSHost
- if api.node.config.WSHost != "" {
- h = api.node.config.WSHost
- }
- host = &h
- }
- if port == nil {
- port = &api.node.config.WSPort
- }
-
- origins := api.node.config.WSOrigins
- if allowedOrigins != nil {
- origins = nil
- for _, origin := range strings.Split(*allowedOrigins, ",") {
- origins = append(origins, strings.TrimSpace(origin))
- }
- }
-
- modules := api.node.config.WSModules
- if apis != nil {
- modules = nil
- for _, m := range strings.Split(*apis, ",") {
- modules = append(modules, strings.TrimSpace(m))
- }
- }
-
- if err := api.node.startWS(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, origins, api.node.config.WSExposeAll); err != nil {
- return false, err
- }
- return true, nil
-}
+//// StartWS starts the websocket RPC API server.
+//func (api *PrivateAdminAPI) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error) {
+// api.node.lock.Lock()
+// defer api.node.lock.Unlock()
+//
+// if api.node.wsHandler != nil {
+// return false, fmt.Errorf("WebSocket RPC already running on %s", api.node.wsEndpoint)
+// }
+//
+// if host == nil {
+// h := DefaultWSHost
+// if api.node.config.WSHost != "" {
+// h = api.node.config.WSHost
+// }
+// host = &h
+// }
+// if port == nil {
+// port = &api.node.config.WSPort
+// }
+//
+// origins := api.node.config.WSOrigins
+// if allowedOrigins != nil {
+// origins = nil
+// for _, origin := range strings.Split(*allowedOrigins, ",") {
+// origins = append(origins, strings.TrimSpace(origin))
+// }
+// }
+//
+// modules := api.node.config.WSModules
+// if apis != nil {
+// modules = nil
+// for _, m := range strings.Split(*apis, ",") {
+// modules = append(modules, strings.TrimSpace(m))
+// }
+// }
+//
+// if err := api.node.startWS(fmt.Sprintf("%s:%d", *host, *port), api.node.rpcAPIs, modules, origins, api.node.config.WSExposeAll); err != nil {
+// return false, err
+// }
+// return true, nil
+//}
// StopWS terminates an already running websocket RPC API endpoint.
func (api *PrivateAdminAPI) StopWS() (bool, error) {
diff --git a/node/config.go b/node/config.go
index 73704a8..fc036c1 100644
--- a/node/config.go
+++ b/node/config.go
@@ -26,17 +26,17 @@ import (
"strings"
"sync"
- "github.com/ava-labs/go-ethereum/accounts"
- "github.com/ava-labs/go-ethereum/accounts/external"
- "github.com/ava-labs/go-ethereum/accounts/keystore"
- "github.com/ava-labs/go-ethereum/accounts/scwallet"
- "github.com/ava-labs/go-ethereum/accounts/usbwallet"
+ "github.com/ava-labs/coreth/accounts"
+ "github.com/ava-labs/coreth/accounts/external"
+ "github.com/ava-labs/coreth/accounts/keystore"
+ "github.com/ava-labs/coreth/accounts/scwallet"
+ "github.com/ava-labs/coreth/accounts/usbwallet"
+ "github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/crypto"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/p2p"
"github.com/ava-labs/go-ethereum/p2p/enode"
- "github.com/ava-labs/go-ethereum/rpc"
)
const (
diff --git a/node/defaults.go b/node/defaults.go
index 69299a7..1d277e2 100644
--- a/node/defaults.go
+++ b/node/defaults.go
@@ -22,9 +22,9 @@ import (
"path/filepath"
"runtime"
+ "github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/p2p"
"github.com/ava-labs/go-ethereum/p2p/nat"
- "github.com/ava-labs/go-ethereum/rpc"
)
const (
diff --git a/node/node.go b/node/node.go
index e65fc79..6e91b60 100644
--- a/node/node.go
+++ b/node/node.go
@@ -26,14 +26,14 @@ import (
"strings"
"sync"
+ "github.com/ava-labs/coreth/accounts"
+ "github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/internal/debug"
- "github.com/ava-labs/go-ethereum/accounts"
- "github.com/ava-labs/go-ethereum/core/rawdb"
+ "github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/ethdb"
"github.com/ava-labs/go-ethereum/event"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/p2p"
- "github.com/ava-labs/go-ethereum/rpc"
"github.com/prometheus/tsdb/fileutil"
)
@@ -236,13 +236,13 @@ func (n *Node) Start() error {
started = append(started, kind)
}
// Lastly start the configured RPC interfaces
- if err := n.startRPC(services); err != nil {
- for _, service := range services {
- service.Stop()
- }
- running.Stop()
- return err
- }
+ //if err := n.startRPC(services); err != nil {
+ // for _, service := range services {
+ // service.Stop()
+ // }
+ // running.Stop()
+ // return err
+ //}
// Finish initializing the startup
n.services = services
n.server = running
@@ -277,35 +277,35 @@ func (n *Node) openDataDir() error {
// startRPC is a helper method to start all the various RPC endpoint during node
// startup. It's not meant to be called at any time afterwards as it makes certain
// assumptions about the state of the node.
-func (n *Node) startRPC(services map[reflect.Type]Service) error {
- // Gather all the possible APIs to surface
- apis := n.apis()
- for _, service := range services {
- apis = append(apis, service.APIs()...)
- }
- // Start the various API endpoints, terminating all in case of errors
- if err := n.startInProc(apis); err != nil {
- return err
- }
- if err := n.startIPC(apis); err != nil {
- n.stopInProc()
- return err
- }
- if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors, n.config.HTTPVirtualHosts, n.config.HTTPTimeouts); err != nil {
- n.stopIPC()
- n.stopInProc()
- return err
- }
- if err := n.startWS(n.wsEndpoint, apis, n.config.WSModules, n.config.WSOrigins, n.config.WSExposeAll); err != nil {
- n.stopHTTP()
- n.stopIPC()
- n.stopInProc()
- return err
- }
- // All API endpoints started successfully
- n.rpcAPIs = apis
- return nil
-}
+//func (n *Node) startRPC(services map[reflect.Type]Service) error {
+// // Gather all the possible APIs to surface
+// apis := n.apis()
+// for _, service := range services {
+// apis = append(apis, service.APIs()...)
+// }
+// // Start the various API endpoints, terminating all in case of errors
+// if err := n.startInProc(apis); err != nil {
+// return err
+// }
+// if err := n.startIPC(apis); err != nil {
+// n.stopInProc()
+// return err
+// }
+// if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors, n.config.HTTPVirtualHosts, n.config.HTTPTimeouts); err != nil {
+// n.stopIPC()
+// n.stopInProc()
+// return err
+// }
+// if err := n.startWS(n.wsEndpoint, apis, n.config.WSModules, n.config.WSOrigins, n.config.WSExposeAll); err != nil {
+// n.stopHTTP()
+// n.stopIPC()
+// n.stopInProc()
+// return err
+// }
+// // All API endpoints started successfully
+// n.rpcAPIs = apis
+// return nil
+//}
// startInProc initializes an in-process RPC endpoint.
func (n *Node) startInProc(apis []rpc.API) error {
@@ -329,20 +329,20 @@ func (n *Node) stopInProc() {
}
}
-// startIPC initializes and starts the IPC RPC endpoint.
-func (n *Node) startIPC(apis []rpc.API) error {
- if n.ipcEndpoint == "" {
- return nil // IPC disabled.
- }
- listener, handler, err := rpc.StartIPCEndpoint(n.ipcEndpoint, apis)
- if err != nil {
- return err
- }
- n.ipcListener = listener
- n.ipcHandler = handler
- n.log.Info("IPC endpoint opened", "url", n.ipcEndpoint)
- return nil
-}
+//// startIPC initializes and starts the IPC RPC endpoint.
+//func (n *Node) startIPC(apis []rpc.API) error {
+// if n.ipcEndpoint == "" {
+// return nil // IPC disabled.
+// }
+// listener, handler, err := rpc.StartIPCEndpoint(n.ipcEndpoint, apis)
+// if err != nil {
+// return err
+// }
+// n.ipcListener = listener
+// n.ipcHandler = handler
+// n.log.Info("IPC endpoint opened", "url", n.ipcEndpoint)
+// return nil
+//}
// stopIPC terminates the IPC RPC endpoint.
func (n *Node) stopIPC() {
@@ -359,23 +359,23 @@ func (n *Node) stopIPC() {
}
// startHTTP initializes and starts the HTTP RPC endpoint.
-func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts) error {
- // Short circuit if the HTTP endpoint isn't being exposed
- if endpoint == "" {
- return nil
- }
- listener, handler, err := rpc.StartHTTPEndpoint(endpoint, apis, modules, cors, vhosts, timeouts)
- if err != nil {
- return err
- }
- n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ","))
- // All listeners booted successfully
- n.httpEndpoint = endpoint
- n.httpListener = listener
- n.httpHandler = handler
-
- return nil
-}
+//func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts) error {
+// // Short circuit if the HTTP endpoint isn't being exposed
+// if endpoint == "" {
+// return nil
+// }
+// listener, handler, err := rpc.StartHTTPEndpoint(endpoint, apis, modules, cors, vhosts, timeouts)
+// if err != nil {
+// return err
+// }
+// n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ","))
+// // All listeners booted successfully
+// n.httpEndpoint = endpoint
+// n.httpListener = listener
+// n.httpHandler = handler
+//
+// return nil
+//}
// stopHTTP terminates the HTTP RPC endpoint.
func (n *Node) stopHTTP() {
@@ -391,24 +391,24 @@ func (n *Node) stopHTTP() {
}
}
-// startWS initializes and starts the websocket RPC endpoint.
-func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool) error {
- // Short circuit if the WS endpoint isn't being exposed
- if endpoint == "" {
- return nil
- }
- listener, handler, err := rpc.StartWSEndpoint(endpoint, apis, modules, wsOrigins, exposeAll)
- if err != nil {
- return err
- }
- n.log.Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr()))
- // All listeners booted successfully
- n.wsEndpoint = endpoint
- n.wsListener = listener
- n.wsHandler = handler
-
- return nil
-}
+//// startWS initializes and starts the websocket RPC endpoint.
+//func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool) error {
+// // Short circuit if the WS endpoint isn't being exposed
+// if endpoint == "" {
+// return nil
+// }
+// listener, handler, err := rpc.StartWSEndpoint(endpoint, apis, modules, wsOrigins, exposeAll)
+// if err != nil {
+// return err
+// }
+// n.log.Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr()))
+// // All listeners booted successfully
+// n.wsEndpoint = endpoint
+// n.wsListener = listener
+// n.wsHandler = handler
+//
+// return nil
+//}
// stopWS terminates the websocket RPC endpoint.
func (n *Node) stopWS() {
@@ -504,16 +504,16 @@ func (n *Node) Restart() error {
return nil
}
-// Attach creates an RPC client attached to an in-process API handler.
-func (n *Node) Attach() (*rpc.Client, error) {
- n.lock.RLock()
- defer n.lock.RUnlock()
-
- if n.server == nil {
- return nil, ErrNodeStopped
- }
- return rpc.DialInProc(n.inprocHandler), nil
-}
+//// Attach creates an RPC client attached to an in-process API handler.
+//func (n *Node) Attach() (*rpc.Client, error) {
+// n.lock.RLock()
+// defer n.lock.RUnlock()
+//
+// if n.server == nil {
+// return nil, ErrNodeStopped
+// }
+// return rpc.DialInProc(n.inprocHandler), nil
+//}
// RPCHandler returns the in-process RPC request handler.
func (n *Node) RPCHandler() (*rpc.Server, error) {
diff --git a/node/service.go b/node/service.go
index fca9d90..7b3a4ff 100644
--- a/node/service.go
+++ b/node/service.go
@@ -20,12 +20,12 @@ import (
"path/filepath"
"reflect"
- "github.com/ava-labs/go-ethereum/accounts"
- "github.com/ava-labs/go-ethereum/core/rawdb"
+ "github.com/ava-labs/coreth/accounts"
+ "github.com/ava-labs/coreth/core/rawdb"
+ "github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/ethdb"
"github.com/ava-labs/go-ethereum/event"
"github.com/ava-labs/go-ethereum/p2p"
- "github.com/ava-labs/go-ethereum/rpc"
)
// ServiceContext is a collection of service independent options inherited from