Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Sharp authored and Alexey Sharp committed Mar 18, 2021
1 parent 8e4dea5 commit c1de4bd
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion accounts/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
10 changes: 5 additions & 5 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/state_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions core/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package types
import (
"bytes"
"crypto/ecdsa"
"encoding"
"encoding/json"
"fmt"
"math/big"
Expand Down Expand Up @@ -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)
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/eth/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/eth/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions eth/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
3 changes: 1 addition & 2 deletions event/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit c1de4bd

Please sign in to comment.