Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lint issue #2215

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions p2p/consensus_dialed.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (tasks *dialedTasks) InitRemoveConsensusPeerFn(removeConsensusPeerFn remove
}

func (tasks *dialedTasks) AddTask(task *dialTask) error {

// whether the task is already in the queue
// 1 if exists,remove task to the end of the queue;
// 2 if not exists(not exceeding the maximum limit),add new task directly to the end of the queue
Expand All @@ -50,7 +49,6 @@ func (tasks *dialedTasks) AddTask(task *dialTask) error {
}

func (tasks *dialedTasks) RemoveTask(NodeID enode.ID) error {

log.Info("[before remove]Consensus dialed task list before RemoveTask operation", "task queue", tasks.description())
if !tasks.isEmpty() {
for i, t := range tasks.queue {
Expand Down Expand Up @@ -85,7 +83,7 @@ func (tasks *dialedTasks) offer(task *dialTask) {
return pollTask
}*/

// remove the specify index task in the queue
// remove the task at the specified index in the queue
func (tasks *dialedTasks) pollIndex(index int) *dialTask {
if tasks.isEmpty() {
log.Info("dialedTasks is empty!")
Expand Down
3 changes: 2 additions & 1 deletion p2p/netutil/toobig_notwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//+build !windows
//go:build !windows
// +build !windows

package netutil

Expand Down
1 change: 0 additions & 1 deletion p2p/simulations/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ func (s *Server) StopMocker(w http.ResponseWriter, req *http.Request) {

// GetMockerList returns a list of available mockers
func (s *Server) GetMockers(w http.ResponseWriter, req *http.Request) {

list := GetMockerList()
s.JSON(w, http.StatusOK, list)
}
Expand Down
2 changes: 0 additions & 2 deletions p2p/simulations/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ func (t *expectEvents) expect(events ...*Event) {
}

switch expected.Type {

case EventTypeNode:
if event.Node == nil {
t.Fatal("expected event.Node to be set")
Expand All @@ -515,7 +514,6 @@ func (t *expectEvents) expect(events ...*Event) {
if event.Conn.Up != expected.Conn.Up {
t.Fatalf("expected conn event %d to have up=%t, got up=%t", i, expected.Conn.Up, event.Conn.Up)
}

}

i++
Expand Down
1 change: 0 additions & 1 deletion p2p/simulations/mocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
}
wg.Wait()
}

}

// connect nodeCount number of nodes in a ring
Expand Down
4 changes: 0 additions & 4 deletions p2p/simulations/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func (net *Network) watchPeerEvents(id enode.ID, events chan *p2p.PeerEvent, sub
}
peer := event.Peer
switch event.Type {

case p2p.PeerEventTypeAdd:
net.DidConnect(id, peer)

Expand All @@ -248,7 +247,6 @@ func (net *Network) watchPeerEvents(id enode.ID, events chan *p2p.PeerEvent, sub

case p2p.PeerEventTypeMsgRecv:
net.DidReceive(peer, id, event.Protocol, *event.MsgCode)

}

case err := <-sub.Err():
Expand Down Expand Up @@ -928,7 +926,6 @@ func (net *Network) snapshot(addServices []string, removeServices []string) (*Sn
if !haveSvc {
cleanedServices = append(cleanedServices, svc)
}

}
snap.Nodes[i].Node.Config.Lifecycles = cleanedServices
}
Expand Down Expand Up @@ -1022,7 +1019,6 @@ func (net *Network) Load(snap *Snapshot) error {

// Start connecting.
for _, conn := range snap.Conns {

if !net.GetNode(conn.One).Up() || !net.GetNode(conn.Other).Up() {
//in this case, at least one of the nodes of a connection is not up,
//so it would result in the snapshot `Load` to fail
Expand Down
3 changes: 0 additions & 3 deletions p2p/simulations/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
// Tests that a created snapshot with a minimal service only contains the expected connections
// and that a network when loaded with this snapshot only contains those same connections
func TestSnapshot(t *testing.T) {

// PART I
// create snapshot from ring network

Expand Down Expand Up @@ -204,7 +203,6 @@ OuterTwo:
t.Fatal(ctx.Err())
case ev := <-evC:
if ev.Type == EventTypeConn && !ev.Control {

// fail on any disconnect
if !ev.Conn.Up {
t.Fatalf("unexpected disconnect: %v -> %v", ev.Conn.One, ev.Conn.Other)
Expand Down Expand Up @@ -693,7 +691,6 @@ func BenchmarkMinimalService(b *testing.B) {
}

func benchmarkMinimalServiceTmp(b *testing.B) {

// stop timer to discard setup time pollution
args := strings.Split(b.Name(), "/")
nodeCount, err := strconv.ParseInt(args[2], 10, 16)
Expand Down
1 change: 0 additions & 1 deletion rlp/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,6 @@ func TestInvalidOptionalField(t *testing.T) {
t.Errorf("wrong error for %T: %v", test.v, err.Error())
}
}

}

func ExampleDecode() {
Expand Down
2 changes: 1 addition & 1 deletion rpc/client_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package rpc_test
import (
"context"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"time"

"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/rpc"
)

Expand Down
3 changes: 2 additions & 1 deletion rpc/ipc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ package rpc
import (
"context"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/log"
"net"
"os"
"path/filepath"

"github.com/PlatONnetwork/PlatON-Go/log"
)

// ipcListen will create a Unix socket on the given endpoint.
Expand Down
2 changes: 1 addition & 1 deletion rpc/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package rpc

import (
"encoding/json"
"github.com/PlatONnetwork/PlatON-Go/common"
"reflect"
"testing"

"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/common/math"
)

Expand Down
10 changes: 4 additions & 6 deletions signer/core/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"
"os"
"reflect"

"github.com/PlatONnetwork/PlatON-Go/accounts"
"github.com/PlatONnetwork/PlatON-Go/accounts/keystore"
"github.com/PlatONnetwork/PlatON-Go/accounts/scwallet"
Expand All @@ -32,9 +36,6 @@ import (
"github.com/PlatONnetwork/PlatON-Go/rpc"
"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"
"github.com/PlatONnetwork/PlatON-Go/signer/storage"
"math/big"
"os"
"reflect"
)

const (
Expand Down Expand Up @@ -318,7 +319,6 @@ func (api *SignerAPI) openTrezor(url accounts.URL) {
log.Warn("failed to open wallet", "wallet", url, "err", err)
return
}

}

// startUSBListener starts a listener for USB events, for hardware wallet interaction
Expand All @@ -327,7 +327,6 @@ func (api *SignerAPI) startUSBListener() {
am := api.am
am.Subscribe(events)
go func() {

// Open any wallets already attached
for _, wallet := range am.Wallets() {
if err := wallet.Open(""); err != nil {
Expand Down Expand Up @@ -608,7 +607,6 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args apitypes.SendTxA
api.UI.OnApprovedTx(response)
// ...and to the external caller
return &response, nil

}

func (api *SignerAPI) SignGnosisSafeTx(ctx context.Context, signerAddress common.MixedcaseAddress, gnosisTx GnosisSafeTx, methodSelector *string) (*GnosisSafeTx, error) {
Expand Down
16 changes: 6 additions & 10 deletions signer/core/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ import (
"bytes"
"context"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/accounts"
"github.com/PlatONnetwork/PlatON-Go/signer/core"
"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"
"github.com/PlatONnetwork/PlatON-Go/signer/fourbyte"
"github.com/PlatONnetwork/PlatON-Go/signer/storage"
"math/big"
"os"
"path/filepath"
"testing"
"time"

"github.com/PlatONnetwork/PlatON-Go/accounts"
"github.com/PlatONnetwork/PlatON-Go/accounts/keystore"
"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/core/types"
"github.com/PlatONnetwork/PlatON-Go/internal/ethapi"
"github.com/PlatONnetwork/PlatON-Go/rlp"
"github.com/PlatONnetwork/PlatON-Go/signer/core"
"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"
"github.com/PlatONnetwork/PlatON-Go/signer/fourbyte"
"github.com/PlatONnetwork/PlatON-Go/signer/storage"
)

// Used for testing
Expand All @@ -55,7 +55,6 @@ func (ui *headlessUi) RegisterUIServer(api *core.UIServerAPI) {}
func (ui *headlessUi) OnApprovedTx(tx ethapi.SignTransactionResult) {}

func (ui *headlessUi) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {

switch <-ui.approveCh {
case "Y":
return core.SignTxResponse{request.Transaction, true}, nil
Expand Down Expand Up @@ -125,8 +124,8 @@ func setup(t *testing.T) (*core.SignerAPI, *headlessUi) {
am := core.StartClefAccountManager(tmpDirName(t), true, true, "")
api := core.NewSignerAPI(am, 1337, true, ui, db, true, &storage.NoStorage{})
return api, ui

}

func createAccount(ui *headlessUi, api *core.SignerAPI, t *testing.T) {
ui.approveCh <- "Y"
ui.inputCh <- "a_long_password"
Expand All @@ -139,7 +138,6 @@ func createAccount(ui *headlessUi, api *core.SignerAPI, t *testing.T) {
}

func failCreateAccountWithPassword(ui *headlessUi, api *core.SignerAPI, password string, t *testing.T) {

ui.approveCh <- "Y"
// We will be asked three times to provide a suitable password
ui.inputCh <- password
Expand Down Expand Up @@ -169,7 +167,6 @@ func failCreateAccount(ui *headlessUi, api *core.SignerAPI, t *testing.T) {
func list(ui *headlessUi, api *core.SignerAPI, t *testing.T) ([]common.Address, error) {
ui.approveCh <- "A"
return api.List(context.Background())

}

func TestNewAcc(t *testing.T) {
Expand Down Expand Up @@ -318,5 +315,4 @@ func TestSignTx(t *testing.T) {
if bytes.Equal(res.Raw, res2.Raw) {
t.Error("Expected tx to be modified by UI")
}

}
9 changes: 5 additions & 4 deletions signer/core/apitypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/accounts"
"github.com/PlatONnetwork/PlatON-Go/common/math"
"github.com/PlatONnetwork/PlatON-Go/crypto"
"math/big"
"reflect"
"regexp"
Expand All @@ -33,6 +30,10 @@ import (
"unicode"
"unicode/utf8"

"github.com/PlatONnetwork/PlatON-Go/common/math"
"github.com/PlatONnetwork/PlatON-Go/crypto"

"github.com/PlatONnetwork/PlatON-Go/accounts"
"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/core/types"
Expand Down Expand Up @@ -64,7 +65,7 @@ func (vs *ValidationMessages) Info(msg string) {
vs.Messages = append(vs.Messages, ValidationInfo{INFO, msg})
}

/// getWarnings returns an error with all messages of type WARN of above, or nil if no warnings were present
// GetWarnings returns an error with all messages of type WARN of above, or nil if no warnings were present
func (v *ValidationMessages) GetWarnings() error {
var messages []string
for _, msg := range v.Messages {
Expand Down
2 changes: 1 addition & 1 deletion signer/core/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package core
import (
"context"
"encoding/json"

"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"

"github.com/PlatONnetwork/PlatON-Go/common"
Expand Down Expand Up @@ -110,7 +111,6 @@ func (l *AuditLogger) Version(ctx context.Context) (string, error) {
data, err := l.api.Version(ctx)
l.log.Info("Version", "type", "response", "data", data, "error", err)
return data, err

}

func NewAuditLogger(path string, api ExternalAPI) (*AuditLogger, error) {
Expand Down
11 changes: 3 additions & 8 deletions signer/core/cliui.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"bufio"
"encoding/json"
"fmt"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/console/prompt"
"os"
"strings"

"sync"

"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/console/prompt"

"github.com/PlatONnetwork/PlatON-Go/internal/ethapi"
"github.com/PlatONnetwork/PlatON-Go/log"
)
Expand Down Expand Up @@ -60,9 +60,7 @@ func (ui *CommandlineUI) readString() string {
}

func (ui *CommandlineUI) OnInputRequired(info UserInputRequest) (UserInputResponse, error) {

fmt.Printf("## %s\n\n%s\n", info.Title, info.Prompt)
defer fmt.Println("-----------------------")
if info.IsPassword {
text, err := prompt.Stdin.PromptPassword("> ")
if err != nil {
Expand Down Expand Up @@ -148,7 +146,6 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
fmt.Printf(" * %s : %s\n", m.Typ, m.Message)
}
fmt.Println()

}
fmt.Printf("\n")
showMetadata(request.Meta)
Expand Down Expand Up @@ -210,7 +207,6 @@ func (ui *CommandlineUI) ApproveListing(request *ListRequest) (ListResponse, err

// ApproveNewAccount prompt the user for confirmation to create new Account, and reveal to caller
func (ui *CommandlineUI) ApproveNewAccount(request *NewAccountRequest) (NewAccountResponse, error) {

ui.mu.Lock()
defer ui.mu.Unlock()

Expand Down Expand Up @@ -246,7 +242,6 @@ func (ui *CommandlineUI) OnApprovedTx(tx ethapi.SignTransactionResult) {
}

func (ui *CommandlineUI) OnSignerStartup(info StartupInfo) {

fmt.Printf("------- Signer info -------\n")
for k, v := range info.Info {
fmt.Printf("* %v : %v\n", k, v)
Expand Down
2 changes: 1 addition & 1 deletion signer/core/gnosis_safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package core

import (
"fmt"
"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"
"math/big"

"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/common/math"
"github.com/PlatONnetwork/PlatON-Go/signer/core/apitypes"
)

// GnosisSafeTx is a type to parse the safe-tx returned by the relayer,
Expand Down
Loading
Loading