Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Mar 19, 2024
1 parent 8e6b236 commit 52e320a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 8 additions & 4 deletions lib/gethfork/node/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package node
import (
"net/http"

"github.com/ten-protocol/go-ten/tools/walletextension/api"

gethlog "github.com/ethereum/go-ethereum/log"
"github.com/ten-protocol/go-ten/go/common/log"
"github.com/ten-protocol/go-ten/lib/gethfork/rpc"
Expand All @@ -27,12 +25,18 @@ type RPCConfig struct {
ExposedURLParamNames []string
}

// Route defines the path plus handler for a given path
type Route struct {
Name string
Func func(resp http.ResponseWriter, req *http.Request)
}

// Server manages the lifeycle of an RPC Server
type Server interface {
Start() error
Stop()
RegisterAPIs(apis []rpc.API)
RegisterRoutes(routes []api.Route)
RegisterRoutes(routes []Route)
}

// An implementation of `host.Server` that reuses the Geth `node` package for client communication.
Expand Down Expand Up @@ -73,7 +77,7 @@ func (s *serverImpl) RegisterAPIs(apis []rpc.API) {
s.node.RegisterAPIs(apis)
}

func (s *serverImpl) RegisterRoutes(routes []api.Route) {
func (s *serverImpl) RegisterRoutes(routes []Route) {
for _, route := range routes {
s.node.RegisterHandler(route.Name, route.Name, http.HandlerFunc(route.Func))
}
Expand Down
16 changes: 6 additions & 10 deletions tools/walletextension/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"net/http"

"github.com/ten-protocol/go-ten/lib/gethfork/node"

"github.com/ten-protocol/go-ten/go/common/log"

"github.com/ten-protocol/go-ten/go/common/httputil"
Expand All @@ -17,15 +19,9 @@ import (
gethcommon "github.com/ethereum/go-ethereum/common"
)

// Route defines the path plus handler for a given path
type Route struct {
Name string
Func func(resp http.ResponseWriter, req *http.Request)
}

// NewHTTPRoutes returns the http specific routes
func NewHTTPRoutes(walletExt *walletextension.WalletExtension) []Route {
return []Route{
func NewHTTPRoutes(walletExt *walletextension.WalletExtension) []node.Route {
return []node.Route{
{
Name: common.APIVersion1 + common.PathRoot,
Func: httpHandler(walletExt, ethRequestHandler),
Expand Down Expand Up @@ -95,8 +91,8 @@ func httpRequestHandler(walletExt *walletextension.WalletExtension, resp http.Re
}

// NewWSRoutes returns the WS specific routes
func NewWSRoutes(walletExt *walletextension.WalletExtension) []Route {
return []Route{
func NewWSRoutes(walletExt *walletextension.WalletExtension) []node.Route {
return []node.Route{
{
Name: common.PathRoot,
Func: wsHandler(walletExt, ethRequestHandler),
Expand Down

0 comments on commit 52e320a

Please sign in to comment.