mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
and more lint fixes
This commit is contained in:
parent
90edad9852
commit
a122920fa8
@ -320,7 +320,7 @@ func saveFile(baseDir, filename string, data interface{}) error {
|
||||
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
|
||||
}
|
||||
location := path.Join(baseDir, filename)
|
||||
if err = ioutil.WriteFile(location, b, 0644); err != nil {
|
||||
if err = ioutil.WriteFile(location, b, 0644); err != nil { //nolint:gosec
|
||||
return NewError(ErrorIO, fmt.Errorf("failed writing output: %v", err))
|
||||
}
|
||||
log.Info("Wrote file", "file", location)
|
||||
|
@ -263,7 +263,7 @@ func (w *wizard) manageGenesis() {
|
||||
|
||||
// Export the native genesis spec used by puppeth and Geth
|
||||
gethJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network))
|
||||
if err := ioutil.WriteFile(gethJson, out, 0644); err != nil {
|
||||
if err := ioutil.WriteFile(gethJson, out, 0644); err != nil { //nolint:gosec
|
||||
log.Error("Failed to save genesis file", "err", err)
|
||||
return
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest) (Pa
|
||||
}
|
||||
var gethTrace GethTrace
|
||||
jsonStr, _ := traceJSON.MarshalJSON()
|
||||
json.Unmarshal(jsonStr, &gethTrace) // nolint errcheck
|
||||
json.Unmarshal(jsonStr, &gethTrace) // nolint:errcheck
|
||||
converted := api.convertToParityTrace(gethTrace, blockHash, blockNumber, txn, txIndex, []int{})
|
||||
traces = append(traces, converted...)
|
||||
}
|
||||
@ -387,7 +387,7 @@ func (api *TraceAPIImpl) getTransactionTraces(tx ethdb.Database, ctx context.Con
|
||||
var gethTrace GethTrace
|
||||
jsonStr, _ := traceJSON.MarshalJSON()
|
||||
// Time spent 26 out of 205
|
||||
json.Unmarshal(jsonStr, &gethTrace) // nolint errcheck
|
||||
json.Unmarshal(jsonStr, &gethTrace) // nolint:errcheck
|
||||
|
||||
traces := ParityTraces{}
|
||||
// Time spent 3 out of 205
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func getFreeDiskSpace(path string) (uint64, error) { //nolint:deadcode
|
||||
func getFreeDiskSpace(path string) (uint64, error) { //nolint:deadcode, unused
|
||||
var stat unix.Statfs_t
|
||||
if err := unix.Statfs(path, &stat); err != nil {
|
||||
return 0, fmt.Errorf("failed to call Statfs: %v", err)
|
||||
|
@ -191,7 +191,7 @@ func (b *BlockGen) GetReceipts() []*types.Receipt {
|
||||
}
|
||||
|
||||
// makeBlockChain creates a deterministic chain of blocks rooted at parent.
|
||||
func makeBlockChain(parent *types.Block, n int, engine consensus.Engine, db *ethdb.ObjectDatabase, seed int) []*types.Block {
|
||||
func makeBlockChain(parent *types.Block, n int, engine consensus.Engine, db *ethdb.ObjectDatabase, seed int) []*types.Block { //nonlint:unused
|
||||
blocks, _, _ := GenerateChain(params.TestChainConfig, parent, engine, db, n, func(i int, b *BlockGen) {
|
||||
b.SetCoinbase(common.Address{0: byte(seed), 19: byte(i)})
|
||||
}, false /*intermediate hashes*/)
|
||||
@ -199,7 +199,7 @@ func makeBlockChain(parent *types.Block, n int, engine consensus.Engine, db *eth
|
||||
}
|
||||
|
||||
// makeHeaderChain creates a deterministic chain of headers rooted at parent.
|
||||
func makeHeaderChain(parent *types.Header, n int, engine consensus.Engine, db *ethdb.ObjectDatabase, seed int) []*types.Header {
|
||||
func makeHeaderChain(parent *types.Header, n int, engine consensus.Engine, db *ethdb.ObjectDatabase, seed int) []*types.Header { //nolint:unused
|
||||
blocks := makeBlockChain(types.NewBlockWithHeader(parent), n, engine, db, seed)
|
||||
headers := make([]*types.Header, len(blocks))
|
||||
for i, block := range blocks {
|
||||
|
@ -62,7 +62,7 @@ func testInsert(t *testing.T, hc *HeaderChain, chain []*types.Header, wantStatus
|
||||
|
||||
status, err := hc.InsertHeaderChain(chain, time.Now()) //nolint:staticcheck
|
||||
if status != wantStatus {
|
||||
t.Errorf("wrong write status from InsertHeaderChain: got %v, want %v", status, wantStatus)
|
||||
t.Errorf("wrong write status from InsertHeaderChain: got %v, want %v, err=%v", status, wantStatus, err)
|
||||
}
|
||||
// Always verify that the header chain is unbroken
|
||||
if err = verifyUnbrokenCanonchain(hc); err != nil {
|
||||
|
@ -96,7 +96,7 @@ func (tx *AccessListTx) copy() TxData {
|
||||
|
||||
func (tx *AccessListTx) txType() byte { return AccessListTxType }
|
||||
func (tx *AccessListTx) chainID() *uint256.Int { return tx.ChainID }
|
||||
func (tx *AccessListTx) protected() bool { return true }
|
||||
func (tx *AccessListTx) protected() bool { return true } //nolint:unused
|
||||
func (tx *AccessListTx) accessList() AccessList { return tx.AccessList }
|
||||
func (tx *AccessListTx) data() []byte { return tx.Data }
|
||||
func (tx *AccessListTx) gas() uint64 { return tx.Gas }
|
||||
|
@ -96,5 +96,5 @@ func SignFile(input string, output string, key string, untrustedComment string,
|
||||
fmt.Fprintln(out, base64.StdEncoding.EncodeToString(dataSig))
|
||||
fmt.Fprintln(out, "trusted comment:", trustedComment)
|
||||
fmt.Fprintln(out, base64.StdEncoding.EncodeToString(commentSig))
|
||||
return ioutil.WriteFile(output, out.Bytes(), 0644)
|
||||
return ioutil.WriteFile(output, out.Bytes(), 0644) //nolint:gosec
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||
if config.SyncMode != downloader.StagedSync {
|
||||
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
|
||||
_ = eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
|
||||
eth.snapDialCandidates, err = setupDiscovery(eth.config.SnapDiscoveryURLs) //nolint:staticcheck
|
||||
eth.snapDialCandidates, _ = setupDiscovery(eth.config.SnapDiscoveryURLs) //nolint:staticcheck
|
||||
}
|
||||
|
||||
if config.SyncMode != downloader.StagedSync {
|
||||
|
@ -156,7 +156,7 @@ func (ps *peerSet) peerWithHighestNumber() *eth.Peer {
|
||||
}
|
||||
|
||||
// peerWithHighestTD is an alias to the highest number for testing and rebase simplicity
|
||||
func (ps *peerSet) peerWithHighestTD() *eth.Peer {
|
||||
func (ps *peerSet) peerWithHighestTD() *eth.Peer { //nolint:unused
|
||||
return ps.peerWithHighestNumber()
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ func (p *Peer) RequestOneHeader(hash common.Hash) error {
|
||||
}
|
||||
if p.Version() >= ETH66 {
|
||||
return p2p.Send(p.rw, GetBlockHeadersMsg, &GetBlockHeadersPacket66{
|
||||
RequestId: rand.Uint64(),
|
||||
RequestId: rand.Uint64(), //nolint:gosec
|
||||
GetBlockHeadersPacket: &query,
|
||||
})
|
||||
}
|
||||
@ -433,7 +433,7 @@ func (p *Peer) RequestHeadersByHash(origin common.Hash, amount int, skip int, re
|
||||
}
|
||||
if p.Version() >= ETH66 {
|
||||
return p2p.Send(p.rw, GetBlockHeadersMsg, &GetBlockHeadersPacket66{
|
||||
RequestId: rand.Uint64(),
|
||||
RequestId: rand.Uint64(), //nolint:gosec
|
||||
GetBlockHeadersPacket: &query,
|
||||
})
|
||||
}
|
||||
@ -452,7 +452,7 @@ func (p *Peer) RequestHeadersByNumber(origin uint64, amount int, skip int, rever
|
||||
}
|
||||
if p.Version() >= ETH66 {
|
||||
return p2p.Send(p.rw, GetBlockHeadersMsg, &GetBlockHeadersPacket66{
|
||||
RequestId: rand.Uint64(),
|
||||
RequestId: rand.Uint64(), //nolint:gosec
|
||||
GetBlockHeadersPacket: &query,
|
||||
})
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
package metrics
|
||||
|
||||
// Config contains the configuration for the metric collection.
|
||||
type Config struct {
|
||||
type Config struct { //nolint:maligned
|
||||
Enabled bool `toml:",omitempty"`
|
||||
EnabledExpensive bool `toml:",omitempty"`
|
||||
HTTP string `toml:",omitempty"`
|
||||
|
@ -26,12 +26,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/ledgerwatch/turbo-geth/common/mclock"
|
||||
"github.com/ledgerwatch/turbo-geth/crypto"
|
||||
"github.com/ledgerwatch/turbo-geth/log"
|
||||
"github.com/ledgerwatch/turbo-geth/p2p/enode"
|
||||
"github.com/ledgerwatch/turbo-geth/p2p/enr"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
@ -301,7 +301,7 @@ func (it *randomIterator) pickTree() *clientTree {
|
||||
switch {
|
||||
case canSync:
|
||||
// Pick a random tree.
|
||||
return trees[rand.Intn(len(trees))]
|
||||
return trees[rand.Intn(len(trees))] //nolint:gosec
|
||||
case len(trees) > 0:
|
||||
// No sync action can be performed on any tree right now. The only meaningful
|
||||
// thing to do is waiting for any root record to get updated.
|
||||
|
Loading…
Reference in New Issue
Block a user