Skip to content

Commit

Permalink
lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
giskook committed Oct 13, 2024
1 parent 89a0b98 commit edee1b5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MaxGasPriceLimit = 0
OperateAmount = 0
RequestSignURI = "/priapi/v1/assetonchain/ecology/ecologyOperate"
QuerySignURI = "/priapi/v1/assetonchain/ecology/querySignDataByOrderNo"
[HTTP]
[EthTxManager.HTTP]
Enable = false
Host = "0.0.0.0"
Port = "7001"
Expand Down
33 changes: 19 additions & 14 deletions ethtxmanager/server_xlayer.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package ethtxmanager

import (
"net/http"
"encoding/json"
"fmt"
"net"
"github.com/0xPolygonHermez/zkevm-node/log"
"net/http"
"time"
"encoding/json"

"github.com/0xPolygonHermez/zkevm-node/log"
)

const (
authHandler = "/inner/v3/okpool/vault/operate/get"
referOrderId = "referOrderId"
)

// Response is the response structure for the rpc server
type Response struct {
Code int `json:"code"`
Data string `json:"data"`
Expand All @@ -23,20 +25,22 @@ type Response struct {
Message string `json:"message"`
}

func (c *Client) startRPC() error {
func (c *Client) startRPC() {
if c == nil || !c.cfg.HTTP.Enable {
return nil
log.Infof("rpc server is disabled")
return
}
if c.srv != nil {
return fmt.Errorf("server already started")
log.Errorf("server already started")
return
}

address := fmt.Sprintf("%s:%d", c.cfg.HTTP.Host, c.cfg.HTTP.Port)

lis, err := net.Listen("tcp", address)
if err != nil {
log.Errorf("failed to create tcp listener: %v", err)
return err
return
}

mux := http.NewServeMux()
Expand All @@ -52,28 +56,29 @@ func (c *Client) startRPC() error {
if err = c.srv.Serve(lis); err != nil {
if err == http.ErrServerClosed {
log.Infof("http server stopped")
return nil
return
}
log.Errorf("closed http connection: %v", err)
return err
return
}

return nil
return

Check failure on line 65 in ethtxmanager/server_xlayer.go

View workflow job for this annotation

GitHub Actions / lint

S1023: redundant `return` statement (gosimple)
}

func (c *Client) stopRPC() error {
func (c *Client) stopRPC() {
if c == nil || c.srv == nil {
return nil
return
}

if err := c.srv.Close(); err != nil {
log.Errorf("failed to close http server: %v", err)
return err
return
}

return nil
return

Check failure on line 78 in ethtxmanager/server_xlayer.go

View workflow job for this annotation

GitHub Actions / lint

S1023: redundant `return` statement (gosimple)
}

// ServeHTTP handles the incoming HTTP requests
func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
var resp Response
Expand Down
1 change: 1 addition & 0 deletions ethtxmanager/serverconfig_xlayer.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ethtxmanager

// RPCConfig is the configuration for the rpc server
type RPCConfig struct {
// Enable is the flag to enable the rpc server
Enable bool `mapstructure:"Enable"`
Expand Down

0 comments on commit edee1b5

Please sign in to comment.