Fix lints

This commit is contained in:
Alexey Sharp 2021-03-18 07:27:50 +00:00
parent 8e4dea56a8
commit c1de4bd0f7
12 changed files with 21 additions and 16 deletions

View File

@ -29,10 +29,10 @@ import (
"strings"
"time"
"github.com/google/uuid"
"github.com/ledgerwatch/turbo-geth/accounts"
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/crypto"
"github.com/google/uuid"
)
const (

View File

@ -38,11 +38,11 @@ import (
"os"
"path/filepath"
"github.com/google/uuid"
"github.com/ledgerwatch/turbo-geth/accounts"
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/common/math"
"github.com/ledgerwatch/turbo-geth/crypto"
"github.com/google/uuid"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
)

View File

@ -198,7 +198,7 @@ func Main(ctx *cli.Context) error {
defer inFile.Close()
decoder := json.NewDecoder(inFile)
if err := decoder.Decode(&txsWithKeys); err != nil {
return NewError(ErrorJson, fmt.Errorf("Failed unmarshaling txs-file: %v", err))
return NewError(ErrorJson, fmt.Errorf("failed unmarshaling txs-file: %v", err))
}
} else {
txsWithKeys = inputData.Txs
@ -207,7 +207,7 @@ func Main(ctx *cli.Context) error {
signer := types.MakeSigner(chainConfig, big.NewInt(int64(prestate.Env.Number)))
if txs, err = signUnsignedTransactions(txsWithKeys, signer); err != nil {
return NewError(ErrorJson, fmt.Errorf("Failed signing transactions: %v", err))
return NewError(ErrorJson, fmt.Errorf("failed signing transactions: %v", err))
}
// Iterate over all the tests, run them and aggregate the results
@ -244,10 +244,10 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error {
}
if key.Key != nil {
k := key.Key.Hex()[2:]
if ecdsaKey, err := crypto.HexToECDSA(k); err != nil {
return err
} else {
if ecdsaKey, err := crypto.HexToECDSA(k); err == nil {
t.key = ecdsaKey
} else {
return err
}
}
// Now, read the transaction itself

View File

@ -831,6 +831,7 @@ func WriteBadBlock(db ethdb.Database, block *types.Block) {
}
// DeleteBadBlocks deletes all the bad blocks from the database
//nolint:interfacer
func DeleteBadBlocks(db ethdb.Database) {
if err := db.Delete(dbutils.InvalidBlock, []byte(dbutils.InvalidBlock), nil); err != nil {
log.Crit("Failed to delete bad blocks", "err", err)

View File

@ -75,7 +75,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, ibs *state.IntraBlockStat
// precacheTransaction attempts to apply a transaction to the given state database
// and uses the input parameters for its environment. The goal is not to execute
// the transaction successfully, rather to warm up touched data slots.
func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs *state.IntraBlockState, header *types.Header, evm *vm.EVM) error {
func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs vm.IntraBlockState, header *types.Header, evm *vm.EVM) error {
// Update the evm with the new transaction context.
evm.Reset(NewEVMTxContext(msg), ibs)
// Add addresses to access list if applicable

View File

@ -1705,7 +1705,7 @@ func (t *txLookup) RemoteToLocals(locals *accountSet) int {
if locals.containsTx(tx) {
t.locals[hash] = tx
delete(t.remotes, hash)
migrated += 1
migrated++
}
}
return migrated

View File

@ -1984,7 +1984,9 @@ func benchmarkFuturePromotion(b *testing.B, size int) {
for i := 0; i < size; i++ {
tx := transaction(uint64(1+i), 100000, key)
pool.enqueueTx(tx.Hash(), tx, false, true)
if _, err := pool.enqueueTx(tx.Hash(), tx, false, true); err != nil {
b.Fatal(err)
}
}
// Benchmark the speed of pool validation
b.ResetTimer()

View File

@ -19,6 +19,7 @@ package types
import (
"bytes"
"crypto/ecdsa"
"encoding"
"encoding/json"
"fmt"
"math/big"
@ -459,7 +460,7 @@ func encodeDecodeJSON(tx *Transaction) (*Transaction, error) {
return parsedTx, nil
}
func encodeDecodeBinary(tx *Transaction) (*Transaction, error) {
func encodeDecodeBinary(tx encoding.BinaryMarshaler) (*Transaction, error) {
data, err := tx.MarshalBinary()
if err != nil {
return nil, fmt.Errorf("rlp encoding failed: %v", err)
@ -481,7 +482,7 @@ func assertEqual(orig *Transaction, cpy *Transaction) error {
}
if orig.AccessList() != nil {
if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) {
return fmt.Errorf("access list wrong!")
return fmt.Errorf("access list wrong")
}
if orig.ChainId().Cmp(cpy.ChainId()) != 0 {
return fmt.Errorf("invalid chain id, want %d, got %d", orig.ChainId(), cpy.ChainId())

View File

@ -58,7 +58,7 @@ func StartENRUpdater(chain *core.BlockChain, ln *enode.LocalNode) {
}
// currentENREntry constructs an `eth` ENR entry based on the current state of the chain.
func currentENREntry(chain *core.BlockChain) *enrEntry {
func currentENREntry(chain forkid.Blockchain) *enrEntry {
return &enrEntry{
ForkID: forkid.NewID(chain.Config(), chain.Genesis().Hash(), chain.CurrentHeader().Number.Uint64()),
}

View File

@ -178,7 +178,7 @@ func TestEth66Messages(t *testing.T) {
// init the receipts
{
receipts = []*types.Receipt{
&types.Receipt{
{
Status: types.ReceiptStatusFailed,
CumulativeGasUsed: 1,
Logs: []*types.Log{

View File

@ -59,9 +59,11 @@ func testFastSyncDisabling(t *testing.T, protocol uint) {
defer emptyPeer.Close()
defer fullPeer.Close()
//nolint:errcheck
go empty.handler.runEthPeer(emptyPeer, func(peer *eth.Peer) error {
return eth.Handle((*ethHandler)(empty.handler), peer)
})
//nolint:errcheck
go full.handler.runEthPeer(fullPeer, func(peer *eth.Peer) error {
return eth.Handle((*ethHandler)(full.handler), peer)
})

View File

@ -137,9 +137,8 @@ func TestResubscribeWithErrorHandler(t *testing.T) {
sub := NewSubscription(func(unsubscribed <-chan struct{}) error {
if i < nfails {
return fmt.Errorf("err-%v", i)
} else {
return nil
}
return nil
})
return sub, nil
})