mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
all: fix linter errors
This commit is contained in:
parent
52f18c83ab
commit
63a4ff7a8d
19 changed files with 91 additions and 83 deletions
|
|
@ -287,9 +287,6 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]int
|
|||
return nil
|
||||
}), nil
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return logs, sub, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -744,21 +744,21 @@ func testExternalUI(api *core.SignerAPI) {
|
|||
api.UI.ShowInfo("Please approve the next request for signing a clique header")
|
||||
time.Sleep(delay)
|
||||
cliqueHeader := types.Header{
|
||||
common.HexToHash("0000H45H"),
|
||||
common.HexToHash("0000H45H"),
|
||||
common.HexToAddress("0000H45H"),
|
||||
common.HexToHash("0000H00H"),
|
||||
common.HexToHash("0000H45H"),
|
||||
common.HexToHash("0000H45H"),
|
||||
types.Bloom{},
|
||||
big.NewInt(1337),
|
||||
big.NewInt(1337),
|
||||
1338,
|
||||
1338,
|
||||
1338,
|
||||
[]byte("Extra data Extra data Extra data Extra data Extra data Extra data Extra data Extra data"),
|
||||
common.HexToHash("0x0000H45H"),
|
||||
types.BlockNonce{},
|
||||
ParentHash: common.HexToHash("0000H45H"),
|
||||
UncleHash: common.HexToHash("0000H45H"),
|
||||
Coinbase: common.HexToAddress("0000H45H"),
|
||||
Root: common.HexToHash("0000H00H"),
|
||||
TxHash: common.HexToHash("0000H45H"),
|
||||
ReceiptHash: common.HexToHash("0000H45H"),
|
||||
Bloom: types.Bloom{},
|
||||
Difficulty: big.NewInt(1337),
|
||||
Number: big.NewInt(1337),
|
||||
GasLimit: 1338,
|
||||
GasUsed: 1338,
|
||||
Time: 1338,
|
||||
Extra: []byte("Extra data Extra data Extra data Extra data Extra data Extra data Extra data Extra data"),
|
||||
MixDigest: common.HexToHash("0x0000H45H"),
|
||||
Nonce: types.BlockNonce{},
|
||||
}
|
||||
cliqueRlp, err := rlp.EncodeToBytes(cliqueHeader)
|
||||
if err != nil {
|
||||
|
|
@ -922,7 +922,7 @@ func GenDoc(ctx *cli.Context) {
|
|||
"of the work in canonicalizing and making sense of the data, and it's up to the UI to present" +
|
||||
"the user with the contents of the `message`"
|
||||
sighash, msg := accounts.TextAndHash([]byte("hello world"))
|
||||
messages := []*core.NameValueType{{"message", msg, accounts.MimetypeTextPlain}}
|
||||
messages := []*core.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
|
||||
|
||||
add("SignDataRequest", desc, &core.SignDataRequest{
|
||||
Address: common.NewMixedcaseAddress(a),
|
||||
|
|
@ -953,8 +953,8 @@ func GenDoc(ctx *cli.Context) {
|
|||
add("SignTxRequest", desc, &core.SignTxRequest{
|
||||
Meta: meta,
|
||||
Callinfo: []core.ValidationInfo{
|
||||
{"Warning", "Something looks odd, show this message as a warning"},
|
||||
{"Info", "User should see this aswell"},
|
||||
{Typ: "Warning", Message: "Something looks odd, show this message as a warning"},
|
||||
{Typ: "Info", Message: "User should see this aswell"},
|
||||
},
|
||||
Transaction: core.SendTxArgs{
|
||||
Data: &data,
|
||||
|
|
@ -1020,16 +1020,16 @@ func GenDoc(ctx *cli.Context) {
|
|||
&core.ListRequest{
|
||||
Meta: meta,
|
||||
Accounts: []accounts.Account{
|
||||
{a, accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/a"}},
|
||||
{b, accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/b"}}},
|
||||
{Address: a, URL: accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/a"}},
|
||||
{Address: b, URL: accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/b"}}},
|
||||
})
|
||||
|
||||
add("ListResponse", "Response to list request. The response contains a list of all addresses to show to the caller. "+
|
||||
"Note: the UI is free to respond with any address the caller, regardless of whether it exists or not",
|
||||
&core.ListResponse{
|
||||
Accounts: []accounts.Account{
|
||||
{common.HexToAddress("0xcowbeef000000cowbeef00000000000000000c0w"), accounts.URL{Path: ".. ignored .."}},
|
||||
{common.HexToAddress("0xffffffffffffffffffffffffffffffffffffffff"), accounts.URL{}},
|
||||
{Address: common.HexToAddress("0xcowbeef000000cowbeef00000000000000000c0w"), URL: accounts.URL{Path: ".. ignored .."}},
|
||||
{Address: common.HexToAddress("0xffffffffffffffffffffffffffffffffffffffff"), URL: accounts.URL{}},
|
||||
}})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ func (c *Clique) snapshot(chain consensus.ChainReader, number uint64, hash commo
|
|||
headers []*types.Header
|
||||
snap *Snapshot
|
||||
)
|
||||
for snap == nil {
|
||||
for /*snap == nil*/ {
|
||||
// If an in-memory snapshot was found, use that
|
||||
if s, ok := c.recents.Get(hash); ok {
|
||||
snap = s.(*Snapshot)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -204,11 +204,9 @@ func TestFreezerRepairDanglingHeadLarge(t *testing.T) {
|
|||
f.Append(uint64(x), data)
|
||||
}
|
||||
// The last item should be there
|
||||
if _, err = f.Retrieve(f.items - 1); err == nil {
|
||||
if err != nil {
|
||||
if _, err = f.Retrieve(f.items - 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
// open the index
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func BenchmarkCutOriginal(b *testing.B) {
|
|||
func BenchmarkCutsetterFn(b *testing.B) {
|
||||
value := common.HexToHash("0x01")
|
||||
cutSetFn := func(r rune) bool {
|
||||
return int32(r) == int32(0)
|
||||
return r == 0
|
||||
}
|
||||
for i := 0; i < b.N; i++ {
|
||||
bytes.TrimLeftFunc(value[:], cutSetFn)
|
||||
|
|
|
|||
|
|
@ -360,65 +360,69 @@ func BenchmarkOpSdiv(b *testing.B) {
|
|||
opBenchmark(b, opSdiv, x, y)
|
||||
}
|
||||
|
||||
const (
|
||||
ABCDEF = "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
)
|
||||
|
||||
func BenchmarkOpMod(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opMod, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpSmod(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opSmod, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpExp(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opExp, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpSignExtend(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opSignExtend, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpLt(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opLt, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpGt(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opGt, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpSlt(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opSlt, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpSgt(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opSgt, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpEq(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opEq, x, y)
|
||||
}
|
||||
|
|
@ -428,45 +432,45 @@ func BenchmarkOpEq2(b *testing.B) {
|
|||
opBenchmark(b, opEq, x, y)
|
||||
}
|
||||
func BenchmarkOpAnd(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opAnd, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpOr(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opOr, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpXor(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opXor, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpByte(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
|
||||
opBenchmark(b, opByte, x, y)
|
||||
}
|
||||
|
||||
func BenchmarkOpAddmod(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
z := ABCDEF
|
||||
|
||||
opBenchmark(b, opAddmod, x, y, z)
|
||||
}
|
||||
|
||||
func BenchmarkOpMulmod(b *testing.B) {
|
||||
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
|
||||
x := ABCDEF
|
||||
y := ABCDEF
|
||||
z := ABCDEF
|
||||
|
||||
opBenchmark(b, opMulmod, x, y, z)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
|
||||
package bn256
|
||||
|
||||
import "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
||||
import bn256 "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
|
||||
|
||||
// G1 is an abstract cyclic group. The zero value is suitable for use as the
|
||||
// output of an operation, but cannot be used as an input.
|
||||
|
|
|
|||
|
|
@ -236,10 +236,8 @@ func (pm *ProtocolManager) removePeer(id string) {
|
|||
log.Error("Peer removal failed", "peer", id, "err", err)
|
||||
}
|
||||
// Hard disconnect at the networking layer
|
||||
if peer != nil {
|
||||
peer.Peer.Disconnect(p2p.DiscUselessPeer)
|
||||
}
|
||||
}
|
||||
|
||||
func (pm *ProtocolManager) Start(maxPeers int) {
|
||||
pm.maxPeers = maxPeers
|
||||
|
|
|
|||
|
|
@ -326,7 +326,8 @@ func testRequest(ctx context.Context, t *testing.T, client *rpc.Client) bool {
|
|||
var res string
|
||||
var addr common.Address
|
||||
rand.Read(addr[:])
|
||||
c, _ := context.WithTimeout(ctx, time.Second*12)
|
||||
c, cf := context.WithTimeout(ctx, time.Second*12)
|
||||
defer cf()
|
||||
err := client.CallContext(c, &res, "eth_getBalance", addr, "latest")
|
||||
if err != nil {
|
||||
t.Log("request error:", err)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func TestCodeAccessLes3(t *testing.T) { testAccess(t, 3, tfCodeAccess) }
|
|||
|
||||
func tfCodeAccess(db ethdb.Database, bhash common.Hash, num uint64) light.OdrRequest {
|
||||
number := rawdb.ReadHeaderNumber(db, bhash)
|
||||
if number != nil {
|
||||
if number == nil {
|
||||
return nil
|
||||
}
|
||||
header := rawdb.ReadHeader(db, bhash, *number)
|
||||
|
|
|
|||
|
|
@ -795,9 +795,7 @@ func (t *UDPv4) handlePacket(from *net.UDPAddr, buf []byte) error {
|
|||
return err
|
||||
}
|
||||
fromID := fromKey.id()
|
||||
if err == nil {
|
||||
err = packet.preverify(t, from, fromID, fromKey)
|
||||
}
|
||||
t.log.Trace("<< "+packet.name(), "id", fromID, "addr", from, "err", err)
|
||||
if err == nil {
|
||||
packet.handle(t, from, fromID, hash)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/jackpal/go-nat-pmp"
|
||||
natpmp "github.com/jackpal/go-nat-pmp"
|
||||
)
|
||||
|
||||
// An implementation of nat.Interface can map local ports to ports
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jackpal/go-nat-pmp"
|
||||
natpmp "github.com/jackpal/go-nat-pmp"
|
||||
)
|
||||
|
||||
// natPMPClient adapts the NAT-PMP protocol implementation so it conforms to
|
||||
|
|
|
|||
|
|
@ -425,6 +425,7 @@ func (t *expectEvents) nodeEvent(id string, up bool) *Event {
|
|||
ID: enode.HexID(id),
|
||||
},
|
||||
up: up,
|
||||
upMu: new(sync.RWMutex),
|
||||
}
|
||||
return &Event{
|
||||
Type: EventTypeNode,
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ func (net *Network) NewNodeWithConfig(conf *adapters.NodeConfig) (*Node, error)
|
|||
node := &Node{
|
||||
Node: adapterNode,
|
||||
Config: conf,
|
||||
upMu: new(sync.RWMutex),
|
||||
}
|
||||
log.Trace("Node created", "id", conf.ID)
|
||||
net.nodeMap[conf.ID] = len(net.Nodes)
|
||||
|
|
@ -631,9 +632,19 @@ type Node struct {
|
|||
|
||||
// up tracks whether or not the node is running
|
||||
up bool
|
||||
upMu sync.RWMutex
|
||||
upMu *sync.RWMutex
|
||||
}
|
||||
|
||||
/*
|
||||
func (n *Node) Clone() *Node {
|
||||
return &Node{
|
||||
Node: n.Node,
|
||||
Config: n.Config,
|
||||
up: n.up,
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func (n *Node) Up() bool {
|
||||
n.upMu.RLock()
|
||||
defer n.upMu.RUnlock()
|
||||
|
|
@ -695,6 +706,7 @@ func (n *Node) UnmarshalJSON(raw []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
n.upMu = new(sync.RWMutex)
|
||||
n.SetUp(node.Up)
|
||||
n.Config = node.Config
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -544,7 +544,9 @@ func expectErrorMessageToContain(t *testing.T, got error, want string) {
|
|||
|
||||
func expectNodeEquality(t *testing.T, got Node, want Node) {
|
||||
t.Helper()
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
if got.up != want.up ||
|
||||
!reflect.DeepEqual(got.Node, want.Node) ||
|
||||
!reflect.DeepEqual(got.Config, want.Config) {
|
||||
t.Errorf("Node.UnmarshalJSON() = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ func TestJsonFiles(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
var typedData core.TypedData
|
||||
err = json.Unmarshal([]byte(data), &typedData)
|
||||
err = json.Unmarshal(data, &typedData)
|
||||
if err != nil {
|
||||
t.Errorf("Test %d, file %v, json unmarshalling failed: %v", i, fInfo.Name(), err)
|
||||
continue
|
||||
|
|
@ -390,7 +390,7 @@ func TestFuzzerFiles(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
var typedData core.TypedData
|
||||
err = json.Unmarshal([]byte(data), &typedData)
|
||||
err = json.Unmarshal(data, &typedData)
|
||||
if err != nil {
|
||||
t.Errorf("Test %d, file %v, json unmarshalling failed: %v", i, fInfo.Name(), err)
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -527,9 +527,6 @@ func (whisper *Whisper) AddSymKeyFromPassword(password string) (string, error) {
|
|||
// kdf should run no less than 0.1 seconds on an average computer,
|
||||
// because it's an once in a session experience
|
||||
derived := pbkdf2.Key([]byte(password), nil, 65356, aesKeyLength, sha256.New)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
whisper.keyMu.Lock()
|
||||
defer whisper.keyMu.Unlock()
|
||||
|
|
|
|||
Loading…
Reference in a new issue