From d235e2c6a5788ec4a6cff15a16f56b38a3876a0d Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 28 Jun 2020 14:47:41 -0400 Subject: ... --- node/api.go | 184 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'node/api.go') 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) { -- cgit v1.2.3 From 67ae6a33a4bfd74dad0a043f07f91647d34cff8d Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 3 Jul 2020 10:54:47 -0400 Subject: more clean up --- node/api.go | 116 ------------------------------------------------------------ 1 file changed, 116 deletions(-) (limited to 'node/api.go') diff --git a/node/api.go b/node/api.go index 8352020..5e93580 100644 --- a/node/api.go +++ b/node/api.go @@ -142,122 +142,6 @@ 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 -//} - -// StopRPC terminates an already running HTTP RPC API endpoint. -func (api *PrivateAdminAPI) StopRPC() (bool, error) { - api.node.lock.Lock() - defer api.node.lock.Unlock() - - if api.node.httpHandler == nil { - return false, fmt.Errorf("HTTP RPC not running") - } - api.node.stopHTTP() - 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) { - api.node.lock.Lock() - defer api.node.lock.Unlock() - - if api.node.wsHandler == nil { - return false, fmt.Errorf("WebSocket RPC not running") - } - api.node.stopWS() - return true, nil -} - // PublicAdminAPI is the collection of administrative API methods exposed over // both secure and unsecure RPC channels. type PublicAdminAPI struct { -- cgit v1.2.3