aboutsummaryrefslogtreecommitdiff
path: root/node/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'node/api.go')
-rw-r--r--node/api.go184
1 files changed, 92 insertions, 92 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) {