all: fix some lint errors

This commit is contained in:
zhiqiangxu 2024-04-08 23:54:06 +08:00
parent c170cc0ab0
commit 94a42f8843
9 changed files with 18 additions and 27 deletions

View file

@ -2340,7 +2340,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
} }
} }
} else { } else {
inserter = func(blocks []*types.Block, receipts []types.Receipts) error { inserter = func(blocks []*types.Block, _ []types.Receipts) error {
_, err := chain.InsertChain(blocks) _, err := chain.InsertChain(blocks)
return err return err
} }
@ -2514,7 +2514,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
} }
} }
} else { } else {
inserter = func(blocks []*types.Block, receipts []types.Receipts) error { inserter = func(blocks []*types.Block, _ []types.Receipts) error {
i, err := chain.InsertChain(blocks) i, err := chain.InsertChain(blocks)
if err != nil { if err != nil {
return fmt.Errorf("index %d: %w", i, err) return fmt.Errorf("index %d: %w", i, err)
@ -2719,7 +2719,7 @@ func testReorgToShorterRemovesCanonMappingHeaderChain(t *testing.T, scheme strin
} }
// Benchmarks large blocks with value transfers to non-existing accounts // Benchmarks large blocks with value transfers to non-existing accounts
func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks int, recipientFn func(uint64) common.Address, dataFn func(uint64) []byte) { func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks int, recipientFn func(uint64) common.Address) {
var ( var (
signer = types.HomesteadSigner{} signer = types.HomesteadSigner{}
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
@ -2782,10 +2782,7 @@ func BenchmarkBlockChain_1x1000ValueTransferToNonexisting(b *testing.B) {
recipientFn := func(nonce uint64) common.Address { recipientFn := func(nonce uint64) common.Address {
return common.BigToAddress(new(big.Int).SetUint64(1337 + nonce)) return common.BigToAddress(new(big.Int).SetUint64(1337 + nonce))
} }
dataFn := func(nonce uint64) []byte { benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
return nil
}
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
} }
func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) { func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) {
@ -2799,10 +2796,7 @@ func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) {
recipientFn := func(nonce uint64) common.Address { recipientFn := func(nonce uint64) common.Address {
return common.BigToAddress(new(big.Int).SetUint64(1337)) return common.BigToAddress(new(big.Int).SetUint64(1337))
} }
dataFn := func(nonce uint64) []byte { benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
return nil
}
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
} }
func BenchmarkBlockChain_1x1000Executions(b *testing.B) { func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
@ -2816,10 +2810,7 @@ func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
recipientFn := func(nonce uint64) common.Address { recipientFn := func(nonce uint64) common.Address {
return common.BigToAddress(new(big.Int).SetUint64(0xc0de)) return common.BigToAddress(new(big.Int).SetUint64(0xc0de))
} }
dataFn := func(nonce uint64) []byte { benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
return nil
}
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
} }
// Tests that importing a some old blocks, where all blocks are before the // Tests that importing a some old blocks, where all blocks are before the

View file

@ -37,6 +37,6 @@ func maxDupStack(n int) int {
func maxStack(pop, push int) int { func maxStack(pop, push int) int {
return int(params.StackLimit) + pop - push return int(params.StackLimit) + pop - push
} }
func minStack(pops, push int) int { func minStack(pops, _ /*push*/ int) int {
return pops return pops
} }

View file

@ -301,7 +301,7 @@ func testParamSelection(t *testing.T, c testCase) {
params := ParamsFromCurve(c.Curve) params := ParamsFromCurve(c.Curve)
if params == nil { if params == nil {
t.Fatal("ParamsFromCurve returned nil") t.Fatal("ParamsFromCurve returned nil")
} else if params != nil && !cmpParams(params, c.Expected) { } else if !cmpParams(params, c.Expected) {
t.Fatalf("ecies: parameters should be invalid (%s)\n", c.Name) t.Fatalf("ecies: parameters should be invalid (%s)\n", c.Name)
} }

View file

@ -657,7 +657,7 @@ func (api *ConsensusAPI) delayPayloadImport(block *types.Block) engine.PayloadSt
api.remoteBlocks.put(block.Hash(), block.Header()) api.remoteBlocks.put(block.Hash(), block.Header())
// Although we don't want to trigger a sync, if there is one already in // Although we don't want to trigger a sync, if there is one already in
// progress, try to extend if with the current payload request to relieve // progress, try to extend it with the current payload request to relieve
// some strain from the forkchoice update. // some strain from the forkchoice update.
err := api.eth.Downloader().BeaconExtend(api.eth.SyncMode(), block.Header()) err := api.eth.Downloader().BeaconExtend(api.eth.SyncMode(), block.Header())
if err == nil { if err == nil {

View file

@ -190,7 +190,7 @@ func (b *testBackend) notifyPending(logs []*types.Log) {
b.chainFeed.Send(core.ChainEvent{Block: blocks[0]}) b.chainFeed.Send(core.ChainEvent{Block: blocks[0]})
} }
func newTestFilterSystem(t testing.TB, db ethdb.Database, cfg Config) (*testBackend, *FilterSystem) { func newTestFilterSystem(_ testing.TB, db ethdb.Database, cfg Config) (*testBackend, *FilterSystem) {
backend := &testBackend{db: db} backend := &testBackend{db: db}
sys := NewFilterSystem(backend, cfg) sys := NewFilterSystem(backend, cfg)
return backend, sys return backend, sys

View file

@ -572,6 +572,6 @@ func ServiceGetTrieNodesQuery(chain *core.BlockChain, req *GetTrieNodesPacket, s
type NodeInfo struct{} type NodeInfo struct{}
// nodeInfo retrieves some `snap` protocol metadata about the running host node. // nodeInfo retrieves some `snap` protocol metadata about the running host node.
func nodeInfo(chain *core.BlockChain) *NodeInfo { func nodeInfo(_ *core.BlockChain) *NodeInfo {
return &NodeInfo{} return &NodeInfo{}
} }

View file

@ -254,7 +254,7 @@ func defaultAccountRequestHandler(t *testPeer, id uint64, root common.Hash, orig
return nil return nil
} }
func createAccountRequestResponse(t *testPeer, root common.Hash, origin common.Hash, limit common.Hash, cap uint64) (keys []common.Hash, vals [][]byte, proofs [][]byte) { func createAccountRequestResponse(t *testPeer, _ /*root*/ common.Hash, origin common.Hash, limit common.Hash, cap uint64) (keys []common.Hash, vals [][]byte, proofs [][]byte) {
var size uint64 var size uint64
if limit == (common.Hash{}) { if limit == (common.Hash{}) {
limit = common.MaxHash limit = common.MaxHash
@ -314,7 +314,7 @@ func defaultCodeRequestHandler(t *testPeer, id uint64, hashes []common.Hash, max
return nil return nil
} }
func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []common.Hash, origin, limit []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) { func createStorageRequestResponse(t *testPeer, _ /*root*/ common.Hash, accounts []common.Hash, origin, limit []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) {
var size uint64 var size uint64
for _, account := range accounts { for _, account := range accounts {
// The first account might start from a different origin and end sooner // The first account might start from a different origin and end sooner
@ -382,7 +382,7 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
// createStorageRequestResponseAlwaysProve tests a cornercase, where the peer always // createStorageRequestResponseAlwaysProve tests a cornercase, where the peer always
// supplies the proof for the last account, even if it is 'complete'. // supplies the proof for the last account, even if it is 'complete'.
func createStorageRequestResponseAlwaysProve(t *testPeer, root common.Hash, accounts []common.Hash, bOrigin, bLimit []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) { func createStorageRequestResponseAlwaysProve(t *testPeer, _ /*root*/ common.Hash, accounts []common.Hash, bOrigin, _ /*bLimit*/ []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) {
var size uint64 var size uint64
max = max * 3 / 4 max = max * 3 / 4

View file

@ -273,7 +273,7 @@ func (t *jsTracer) OnTxEnd(receipt *types.Receipt, err error) {
} }
// onStart implements the Tracer interface to initialize the tracing operation. // onStart implements the Tracer interface to initialize the tracing operation.
func (t *jsTracer) onStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { func (t *jsTracer) onStart(from common.Address, to common.Address, create bool, input []byte, _ /*gas*/ uint64, value *big.Int) {
if t.err != nil { if t.err != nil {
return return
} }
@ -346,7 +346,7 @@ func (t *jsTracer) OnFault(pc uint64, op byte, gas, cost uint64, scope tracing.O
} }
// onEnd is called after the call finishes to finalize the tracing. // onEnd is called after the call finishes to finalize the tracing.
func (t *jsTracer) onEnd(output []byte, gasUsed uint64, err error, reverted bool) { func (t *jsTracer) onEnd(output []byte, _ /*gasUsed*/ uint64, err error, _ /*reverted*/ bool) {
if t.err != nil { if t.err != nil {
return return
} }

View file

@ -138,7 +138,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer,
}, nil }, nil
} }
func newCallTracerObject(ctx *tracers.Context, cfg json.RawMessage) (*callTracer, error) { func newCallTracerObject(_ *tracers.Context, cfg json.RawMessage) (*callTracer, error) {
var config callTracerConfig var config callTracerConfig
if cfg != nil { if cfg != nil {
if err := json.Unmarshal(cfg, &config); err != nil { if err := json.Unmarshal(cfg, &config); err != nil {
@ -204,7 +204,7 @@ func (t *callTracer) OnExit(depth int, output []byte, gasUsed uint64, err error,
t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call) t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call)
} }
func (t *callTracer) captureEnd(output []byte, gasUsed uint64, err error, reverted bool) { func (t *callTracer) captureEnd(output []byte, _ /*gasUsed*/ uint64, err error, reverted bool) {
if len(t.callstack) != 1 { if len(t.callstack) != 1 {
return return
} }