From 26d3fd2ecca3e635c4d269df02741b4eb6cb69a5 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 9 May 2024 12:15:35 +1000 Subject: [PATCH] chore: lint: fix lint errors with new linting config Ref: https://github.com/filecoin-project/lotus/issues/11967 --- blockstore/buffered.go | 6 ++-- blockstore/splitstore/splitstore.go | 4 +-- blockstore/splitstore/splitstore_compact.go | 7 ++-- blockstore/splitstore/splitstore_test.go | 2 +- build/builtin_actors_gen.go | 2 +- build/params_mainnet.go | 2 +- build/params_shared_vals.go | 1 + chain/checkpoint.go | 18 +++++----- chain/messagepool/messagepool.go | 6 ++-- chain/messagepool/selection_test.go | 4 +-- chain/rand/rand.go | 3 +- chain/store/snapshot.go | 2 +- chain/store/store.go | 3 +- chain/sync_test.go | 4 +-- chain/types/ethtypes/eth_types.go | 2 +- chain/vm/vm.go | 7 ++-- cli/backup.go | 2 +- cli/client.go | 6 ++-- cli/info.go | 3 +- cli/init_test.go | 2 +- cli/sending_ui.go | 2 +- cmd/curio/config_test.go | 2 +- cmd/lotus-bench/cli.go | 2 +- cmd/lotus-bench/main.go | 2 +- cmd/lotus-bench/reporter.go | 2 +- cmd/lotus-fountain/main.go | 2 +- cmd/lotus-health/main.go | 2 +- cmd/lotus-miner/sealing.go | 4 +-- cmd/lotus-miner/sectors.go | 18 ++++------ cmd/lotus-seed/main.go | 2 +- cmd/lotus-shed/balances.go | 6 ++-- cmd/lotus-shed/datastore.go | 4 +-- cmd/lotus-shed/diff.go | 6 ++-- cmd/lotus-shed/itestd.go | 2 +- cmd/lotus-shed/market.go | 4 +-- cmd/lotus-shed/rpc.go | 5 ++- cmd/lotus-shed/state-stats.go | 2 +- conformance/chaos/actor.go | 3 +- curiosrc/market/lmrpc/lmrpc.go | 3 +- curiosrc/window/compute_do.go | 4 +-- curiosrc/winning/winning_task.go | 2 +- gateway/proxy_eth.go | 2 +- gen/bundle/bundle.go | 2 +- itests/eth_filter_test.go | 2 +- itests/gas_estimation_test.go | 4 +-- itests/harmonytask_test.go | 2 +- itests/kit/client.go | 2 +- itests/kit/ensemble.go | 6 ++-- itests/splitstore_test.go | 3 +- lib/ulimit/ulimit_test.go | 4 +-- markets/dagstore/miner_api.go | 4 +-- markets/dagstore/miner_api_test.go | 4 +-- miner/miner.go | 2 +- node/health.go | 7 ++-- node/impl/full/chain.go | 4 +-- node/impl/full/eth_utils.go | 37 ++++++++++----------- node/impl/full/state.go | 3 +- node/modules/lp2p/pubsub.go | 8 ++--- node/modules/lp2p/rcmgr.go | 2 +- node/repo/fsrepo.go | 2 +- storage/paths/index_test.go | 2 +- storage/sealer/ffiwrapper/sealer_test.go | 2 +- storage/sealer/manager_post.go | 2 +- storage/sealer/sched_post.go | 2 +- storage/wdpost/wdpost_changehandler_test.go | 6 ++-- storage/wdpost/wdpost_run_faults.go | 2 +- 66 files changed, 128 insertions(+), 153 deletions(-) diff --git a/blockstore/buffered.go b/blockstore/buffered.go index 2a789b637..9cfc12e65 100644 --- a/blockstore/buffered.go +++ b/blockstore/buffered.go @@ -109,11 +109,9 @@ func (bs *BufferedBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) er func (bs *BufferedBlockstore) View(ctx context.Context, c cid.Cid, callback func([]byte) error) error { // both stores are viewable. - if err := bs.write.View(ctx, c, callback); ipld.IsNotFound(err) { - // not found in write blockstore; fall through. - } else { + if err := bs.write.View(ctx, c, callback); !ipld.IsNotFound(err) { return err // propagate errors, or nil, i.e. found. - } + } // else not found in write blockstore; fall through. return bs.read.View(ctx, c, callback) } diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index c1a95c8b0..6da1cf7f3 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -282,14 +282,14 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co if ss.checkpointExists() { log.Info("found compaction checkpoint; resuming compaction") if err := ss.completeCompaction(); err != nil { - markSetEnv.Close() //nolint:errcheck + _ = markSetEnv.Close() return nil, xerrors.Errorf("error resuming compaction: %w", err) } } if ss.pruneCheckpointExists() { log.Info("found prune checkpoint; resuming prune") if err := ss.completePrune(); err != nil { - markSetEnv.Close() //nolint:errcheck + _ = markSetEnv.Close() return nil, xerrors.Errorf("error resuming prune: %w", err) } } diff --git a/blockstore/splitstore/splitstore_compact.go b/blockstore/splitstore/splitstore_compact.go index 47caca886..c8e4caa45 100644 --- a/blockstore/splitstore/splitstore_compact.go +++ b/blockstore/splitstore/splitstore_compact.go @@ -109,16 +109,13 @@ func (s *SplitStore) HeadChange(_, apply []*types.TipSet) error { // TODO: ok to use hysteresis with no transitions between 30s and 1m? if time.Since(timestamp) < SyncWaitTime { /* Chain in sync */ - if atomic.CompareAndSwapInt32(&s.outOfSync, 0, 0) { - // already in sync, no signaling necessary - } else { + if !atomic.CompareAndSwapInt32(&s.outOfSync, 0, 0) { // transition from out of sync to in sync s.chainSyncMx.Lock() s.chainSyncFinished = true s.chainSyncCond.Broadcast() s.chainSyncMx.Unlock() - } - + } // else already in sync, no signaling necessary } // 2. protect the new tipset(s) s.protectTipSets(apply) diff --git a/blockstore/splitstore/splitstore_test.go b/blockstore/splitstore/splitstore_test.go index 1b821654d..b28f45c84 100644 --- a/blockstore/splitstore/splitstore_test.go +++ b/blockstore/splitstore/splitstore_test.go @@ -32,7 +32,7 @@ func init() { CompactionBoundary = 2 WarmupBoundary = 0 SyncWaitTime = time.Millisecond - logging.SetLogLevel("splitstore", "DEBUG") + _ = logging.SetLogLevel("splitstore", "DEBUG") } func testSplitStore(t *testing.T, cfg *Config) { diff --git a/build/builtin_actors_gen.go b/build/builtin_actors_gen.go index b1920cc98..8107e1d54 100644 --- a/build/builtin_actors_gen.go +++ b/build/builtin_actors_gen.go @@ -6,7 +6,7 @@ import ( "github.com/ipfs/go-cid" ) -var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMetadata{{ +var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{ Network: "butterflynet", Version: 8, diff --git a/build/params_mainnet.go b/build/params_mainnet.go index 609c3bd22..e79acdca3 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -166,5 +166,5 @@ const BootstrapPeerThreshold = 4 // As per https://github.com/ethereum-lists/chains const Eip155ChainId = 314 -// we skip checks on message validity in this block to sidestep the zero-bls signature +// WhitelistedBlock skips checks on message validity in this block to sidestep the zero-bls signature var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi") diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index aab170499..25cfdd2ea 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -124,6 +124,7 @@ const MinimumBaseFee = 100 const PackingEfficiencyNum = 4 const PackingEfficiencyDenom = 5 +// revive:disable-next-line:exported // Actor consts // TODO: pieceSize unused from actors var MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) diff --git a/chain/checkpoint.go b/chain/checkpoint.go index 2810b1e4a..766af95b4 100644 --- a/chain/checkpoint.go +++ b/chain/checkpoint.go @@ -25,15 +25,15 @@ func (syncer *Syncer) SyncCheckpoint(ctx context.Context, tsk types.TipSetKey) e } hts := syncer.ChainStore().GetHeaviestTipSet() - if hts.Equals(ts) { - // Current head, no need to switch. - } else if anc, err := syncer.store.IsAncestorOf(ctx, ts, hts); err != nil { - return xerrors.Errorf("failed to walk the chain when checkpointing: %w", err) - } else if anc { - // New checkpoint is on the current chain, we definitely have the tipsets. - } else if err := syncer.collectChain(ctx, ts, hts, true); err != nil { - return xerrors.Errorf("failed to collect chain for checkpoint: %w", err) - } + if !hts.Equals(ts) { + if anc, err := syncer.store.IsAncestorOf(ctx, ts, hts); err != nil { + return xerrors.Errorf("failed to walk the chain when checkpointing: %w", err) + } else if !anc { + if err := syncer.collectChain(ctx, ts, hts, true); err != nil { + return xerrors.Errorf("failed to collect chain for checkpoint: %w", err) + } + } // else new checkpoint is on the current chain, we definitely have the tipsets. + } // else current head, no need to switch. if err := syncer.ChainStore().SetCheckpoint(ctx, ts); err != nil { return xerrors.Errorf("failed to set the chain checkpoint: %w", err) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 7d55b0b16..c8a2493fa 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -778,9 +778,7 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { _, _ = mp.getStateNonce(ctx, m.Message.From, tmpCurTs) mp.curTsLk.Lock() - if tmpCurTs == mp.curTs { - //with the lock enabled, mp.curTs is the same Ts as we just had, so we know that our computations are cached - } else { + if tmpCurTs != mp.curTs { //curTs has been updated so we want to cache the new one: tmpCurTs = mp.curTs //we want to release the lock, cache the computations then grab it again @@ -789,7 +787,7 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { _, _ = mp.getStateNonce(ctx, m.Message.From, tmpCurTs) mp.curTsLk.Lock() //now that we have the lock, we continue, we could do this as a loop forever, but that's bad to loop forever, and this was added as an optimization and it seems once is enough because the computation < block time - } + } // else with the lock enabled, mp.curTs is the same Ts as we just had, so we know that our computations are cached defer mp.curTsLk.Unlock() diff --git a/chain/messagepool/selection_test.go b/chain/messagepool/selection_test.go index 48846bb7e..5b46fadfb 100644 --- a/chain/messagepool/selection_test.go +++ b/chain/messagepool/selection_test.go @@ -1321,7 +1321,7 @@ func testCompetitiveMessageSelection(t *testing.T, rng *rand.Rand, getPremium fu mustAdd(t, mp, m) } - logging.SetLogLevel("messagepool", "error") + _ = logging.SetLogLevel("messagepool", "error") // 1. greedy selection gm, err := mp.selectMessagesGreedy(context.Background(), ts, ts) @@ -1414,7 +1414,7 @@ func testCompetitiveMessageSelection(t *testing.T, rng *rand.Rand, getPremium fu t.Logf("Average reward boost: %f", rewardBoost) t.Logf("Average best tq reward: %f", totalBestTQReward/runs/1e12) - logging.SetLogLevel("messagepool", "info") + _ = logging.SetLogLevel("messagepool", "info") return capacityBoost, rewardBoost, totalBestTQReward / runs / 1e12 } diff --git a/chain/rand/rand.go b/chain/rand/rand.go index 40f9f593a..f892d2aae 100644 --- a/chain/rand/rand.go +++ b/chain/rand/rand.go @@ -184,9 +184,8 @@ func (sr *stateRand) GetBeaconRandomness(ctx context.Context, filecoinEpoch abi. return sr.getBeaconRandomnessV3(ctx, filecoinEpoch) } else if nv == network.Version13 { return sr.getBeaconRandomnessV2(ctx, filecoinEpoch) - } else { - return sr.getBeaconRandomnessV1(ctx, filecoinEpoch) } + return sr.getBeaconRandomnessV1(ctx, filecoinEpoch) } func (sr *stateRand) DrawChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, filecoinEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) { diff --git a/chain/store/snapshot.go b/chain/store/snapshot.go index de2190c5d..ca483c2ef 100644 --- a/chain/store/snapshot.go +++ b/chain/store/snapshot.go @@ -392,7 +392,7 @@ func (s *walkScheduler) Wait() error { log.Errorw("error writing to CAR file", "error", err) return errWrite } - s.workerTasks.Close() //nolint:errcheck + _ = s.workerTasks.Close() return err } diff --git a/chain/store/store.go b/chain/store/store.go index b1431c2ee..9c8c2b2a1 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -305,6 +305,7 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*api.HeadChange // Unsubscribe. cs.bestTips.Unsub(subch) + // revive:disable-next-line:empty-block // Drain the channel. for range subch { } @@ -752,7 +753,7 @@ func FlushValidationCache(ctx context.Context, ds dstore.Batching) error { for _, k := range allKeys { if strings.HasPrefix(k.Key, blockValidationCacheKeyPrefix.String()) { delCnt++ - batch.Delete(ctx, dstore.RawKey(k.Key)) // nolint:errcheck + _ = batch.Delete(ctx, dstore.RawKey(k.Key)) } } diff --git a/chain/sync_test.go b/chain/sync_test.go index 416102366..1b556f879 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -85,7 +85,7 @@ type syncTestUtil struct { } func prepSyncTest(t testing.TB, h int) *syncTestUtil { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") g, err := gen.NewGenerator() if err != nil { @@ -115,7 +115,7 @@ func prepSyncTest(t testing.TB, h int) *syncTestUtil { } func prepSyncTestWithV5Height(t testing.TB, h int, v5height abi.ChainEpoch) *syncTestUtil { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") sched := stmgr.UpgradeSchedule{{ // prepare for upgrade. diff --git a/chain/types/ethtypes/eth_types.go b/chain/types/ethtypes/eth_types.go index 2740a3e9d..893c0721c 100644 --- a/chain/types/ethtypes/eth_types.go +++ b/chain/types/ethtypes/eth_types.go @@ -927,7 +927,7 @@ func NewEthBlockNumberOrHashFromNumber(number EthUint64) EthBlockNumberOrHash { func NewEthBlockNumberOrHashFromHexString(str string) (EthBlockNumberOrHash, error) { // check if block param is a number (decimal or hex) - var num EthUint64 = 0 + var num EthUint64 err := num.UnmarshalJSON([]byte(str)) if err != nil { return NewEthBlockNumberOrHashFromNumber(0), err diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 1e0591b6c..f8a0c3892 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -336,9 +336,7 @@ func (vm *LegacyVM) send(ctx context.Context, msg *types.Message, parent *Runtim return nil, aerrors.Wrapf(err, "could not create account") } toActor = a - if vm.networkVersion <= network.Version3 { - // Leave the rt.Message as is - } else { + if vm.networkVersion > network.Version3 { nmsg := Message{ msg: types.Message{ To: aid, @@ -346,9 +344,8 @@ func (vm *LegacyVM) send(ctx context.Context, msg *types.Message, parent *Runtim Value: rt.Message.ValueReceived(), }, } - rt.Message = &nmsg - } + } // else leave the rt.Message as is } else { return nil, aerrors.Escalate(err, "getting actor") } diff --git a/cli/backup.go b/cli/backup.go index d2d8f25ff..e0495678c 100644 --- a/cli/backup.go +++ b/cli/backup.go @@ -24,7 +24,7 @@ type BackupApiFn func(ctx *cli.Context) (BackupAPI, jsonrpc.ClientCloser, error) func BackupCmd(repoFlag string, rt repo.RepoType, getApi BackupApiFn) *cli.Command { var offlineBackup = func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") // nolint:errcheck + _ = logging.SetLogLevel("badger", "ERROR") repoPath := cctx.String(repoFlag) r, err := repo.NewFS(repoPath) diff --git a/cli/client.go b/cli/client.go index 302e31e98..e40a66866 100644 --- a/cli/client.go +++ b/cli/client.go @@ -574,7 +574,7 @@ func interactiveDeal(cctx *cli.Context) error { cs := readline.NewCancelableStdin(afmt.Stdin) go func() { <-ctx.Done() - cs.Close() // nolint:errcheck + _ = cs.Close() }() rl := bufio.NewReader(cs) @@ -2327,7 +2327,7 @@ func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChann for _, channel := range sendingChannels { w.Write(toChannelOutput("Sending To", channel, verbose)) } - w.Flush(out) //nolint:errcheck + _ = w.Flush(out) fmt.Fprintf(out, "\nReceiving Channels\n\n") w = tablewriter.New(tablewriter.Col("ID"), @@ -2341,7 +2341,7 @@ func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChann for _, channel := range receivingChannels { w.Write(toChannelOutput("Receiving From", channel, verbose)) } - w.Flush(out) //nolint:errcheck + _ = w.Flush(out) } func channelStatusString(status datatransfer.Status) string { diff --git a/cli/info.go b/cli/info.go index a406fc480..01f64dee9 100644 --- a/cli/info.go +++ b/cli/info.go @@ -131,9 +131,8 @@ func infoCmdAct(cctx *cli.Context) error { if err != nil { if strings.Contains(err.Error(), "actor not found") { continue - } else { - return err } + return err } mbLockedSum = big.Add(mbLockedSum, mbal.Locked) mbAvailableSum = big.Add(mbAvailableSum, mbal.Escrow) diff --git a/cli/init_test.go b/cli/init_test.go index 8c343bcfa..59914684b 100644 --- a/cli/init_test.go +++ b/cli/init_test.go @@ -5,5 +5,5 @@ import ( ) func init() { - logging.SetLogLevel("watchdog", "ERROR") + _ = logging.SetLogLevel("watchdog", "ERROR") } diff --git a/cli/sending_ui.go b/cli/sending_ui.go index d2d2ed3c1..c248feb3d 100644 --- a/cli/sending_ui.go +++ b/cli/sending_ui.go @@ -122,7 +122,7 @@ func printChecks(printer io.Writer, checkGroups [][]api.MessageCheckStatus, prot func askUser(printer io.Writer, q string, def bool) bool { var resp string fmt.Fprint(printer, q) - fmt.Scanln(&resp) + _, _ = fmt.Scanln(&resp) resp = strings.ToLower(resp) if len(resp) == 0 { return def diff --git a/cmd/curio/config_test.go b/cmd/curio/config_test.go index f5037abf4..8043017d5 100644 --- a/cmd/curio/config_test.go +++ b/cmd/curio/config_test.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/lotus/node/config" ) -var baseText string = ` +var baseText = ` [Subsystems] # EnableWindowPost enables window post to be executed on this curio instance. Each machine in the cluster # with WindowPoSt enabled will also participate in the window post scheduler. It is possible to have multiple diff --git a/cmd/lotus-bench/cli.go b/cmd/lotus-bench/cli.go index 0eaeb6ccb..4379036d3 100644 --- a/cmd/lotus-bench/cli.go +++ b/cmd/lotus-bench/cli.go @@ -270,7 +270,7 @@ func (c *CMD) startWorker(qpsTicker *time.Ticker) { start := time.Now() - var statusCode int = 0 + var statusCode int arr := strings.Fields(c.cmd) diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 545ed1eb9..1a7a0d087 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -93,7 +93,7 @@ type Commit2In struct { } func main() { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") log.Info("Starting lotus-bench") diff --git a/cmd/lotus-bench/reporter.go b/cmd/lotus-bench/reporter.go index ad2ad6b9d..7ade7b19d 100644 --- a/cmd/lotus-bench/reporter.go +++ b/cmd/lotus-bench/reporter.go @@ -88,7 +88,7 @@ func (r *Reporter) Print(elapsed time.Duration, w io.Writer) { return r.latencies[i] < r.latencies[j] }) - var totalLatency int64 = 0 + var totalLatency int64 for _, latency := range r.latencies { totalLatency += latency } diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index f6d503c2f..36d5faf0c 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -30,7 +30,7 @@ import ( var log = logging.Logger("main") func main() { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") log.Info("Starting fountain") diff --git a/cmd/lotus-health/main.go b/cmd/lotus-health/main.go index a7052f214..59c81e7c9 100644 --- a/cmd/lotus-health/main.go +++ b/cmd/lotus-health/main.go @@ -25,7 +25,7 @@ type CidWindow [][]cid.Cid var log = logging.Logger("lotus-health") func main() { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") log.Info("Starting health agent") diff --git a/cmd/lotus-miner/sealing.go b/cmd/lotus-miner/sealing.go index b2f4dcab9..ed2b2d294 100644 --- a/cmd/lotus-miner/sealing.go +++ b/cmd/lotus-miner/sealing.go @@ -151,7 +151,7 @@ func workersCmd(sealing bool) *cli.Command { ramTotal := stat.Info.Resources.MemPhysical ramTasks := stat.MemUsedMin ramUsed := stat.Info.Resources.MemUsed - var ramReserved uint64 = 0 + var ramReserved uint64 if ramUsed > ramTasks { ramReserved = ramUsed - ramTasks } @@ -167,7 +167,7 @@ func workersCmd(sealing bool) *cli.Command { vmemTotal := stat.Info.Resources.MemPhysical + stat.Info.Resources.MemSwap vmemTasks := stat.MemUsedMax vmemUsed := stat.Info.Resources.MemUsed + stat.Info.Resources.MemSwapUsed - var vmemReserved uint64 = 0 + var vmemReserved uint64 if vmemUsed > vmemTasks { vmemReserved = vmemUsed - vmemTasks } diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index d0c13d333..cf32f4248 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -1305,14 +1305,11 @@ var sectorsBatchingPendingCommit = &cli.Command{ return cctx.Command.Action(cctx) } else if userInput == "no" { return nil - } else { - fmt.Println("Invalid input. Please answer with 'yes' or 'no'.") - return nil } - - } else { - fmt.Println("No sectors queued to be committed") + fmt.Println("Invalid input. Please answer with 'yes' or 'no'.") + return nil } + fmt.Println("No sectors queued to be committed") return nil }, } @@ -1384,14 +1381,11 @@ var sectorsBatchingPendingPreCommit = &cli.Command{ return cctx.Command.Action(cctx) } else if userInput == "no" { return nil - } else { - fmt.Println("Invalid input. Please answer with 'yes' or 'no'.") - return nil } - - } else { - fmt.Println("No sectors queued to be committed") + fmt.Println("Invalid input. Please answer with 'yes' or 'no'.") + return nil } + fmt.Println("No sectors queued to be committed") return nil }, } diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index d362804c9..9deae560e 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -26,7 +26,7 @@ import ( var log = logging.Logger("lotus-seed") func main() { - logging.SetLogLevel("*", "INFO") + _ = logging.SetLogLevel("*", "INFO") local := []*cli.Command{ genesisCmd, diff --git a/cmd/lotus-shed/balances.go b/cmd/lotus-shed/balances.go index 28569cd12..666abbfe8 100644 --- a/cmd/lotus-shed/balances.go +++ b/cmd/lotus-shed/balances.go @@ -685,7 +685,7 @@ var chainPledgeCmd = &cli.Command{ }, ArgsUsage: "[stateroot epoch]", Action: func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") + _ = logging.SetLogLevel("badger", "ERROR") ctx := context.TODO() if !cctx.Args().Present() { @@ -916,13 +916,13 @@ var fillBalancesCmd = &cli.Command{ } w := csv.NewWriter(os.Stdout) - w.Write(append([]string{"Wallet Address"}, datestrs...)) // nolint:errcheck + _ = w.Write(append([]string{"Wallet Address"}, datestrs...)) for i := 0; i < len(addrs); i++ { row := []string{addrs[i].String()} for _, b := range balances[i] { row = append(row, types.FIL(b).String()) } - w.Write(row) // nolint:errcheck + _ = w.Write(row) } w.Flush() return nil diff --git a/cmd/lotus-shed/datastore.go b/cmd/lotus-shed/datastore.go index 5614e34f6..8e31ccc3c 100644 --- a/cmd/lotus-shed/datastore.go +++ b/cmd/lotus-shed/datastore.go @@ -57,7 +57,7 @@ var datastoreListCmd = &cli.Command{ }, ArgsUsage: "[namespace prefix]", Action: func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") // nolint:errcheck + _ = logging.SetLogLevel("badger", "ERROR") r, err := repo.NewFS(cctx.String("repo")) if err != nil { @@ -123,7 +123,7 @@ var datastoreGetCmd = &cli.Command{ }, ArgsUsage: "[namespace key]", Action: func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") // nolint:errcheck + _ = logging.SetLogLevel("badger", "ERROR") r, err := repo.NewFS(cctx.String("repo")) if err != nil { diff --git a/cmd/lotus-shed/diff.go b/cmd/lotus-shed/diff.go index a8eac6575..bdd2126b6 100644 --- a/cmd/lotus-shed/diff.go +++ b/cmd/lotus-shed/diff.go @@ -253,9 +253,8 @@ var diffStateTrees = &cli.Command{ if ok { diff(stateA, stateB) continue - } else { - fmt.Printf(" actor does not exist in second state-tree (%s)\n", rootB) } + fmt.Printf(" actor does not exist in second state-tree (%s)\n", rootB) fmt.Println() delete(changedB, addr) } @@ -265,9 +264,8 @@ var diffStateTrees = &cli.Command{ if ok { diff(stateA, stateB) continue - } else { - fmt.Printf(" actor does not exist in first state-tree (%s)\n", rootA) } + fmt.Printf(" actor does not exist in first state-tree (%s)\n", rootA) fmt.Println() } return nil diff --git a/cmd/lotus-shed/itestd.go b/cmd/lotus-shed/itestd.go index 7b9b7460d..0ff371322 100644 --- a/cmd/lotus-shed/itestd.go +++ b/cmd/lotus-shed/itestd.go @@ -64,7 +64,7 @@ var itestdCmd = &cli.Command{ cs := readline.NewCancelableStdin(os.Stdin) go func() { <-cctx.Done() - cs.Close() // nolint:errcheck + _ = cs.Close() }() rl := bufio.NewReader(cs) diff --git a/cmd/lotus-shed/market.go b/cmd/lotus-shed/market.go index 6fb1566b6..749941f4c 100644 --- a/cmd/lotus-shed/market.go +++ b/cmd/lotus-shed/market.go @@ -214,7 +214,7 @@ var marketExportDatastoreCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") // nolint:errcheck + _ = logging.SetLogLevel("badger", "ERROR") // If the backup dir is not specified, just use the OS temp dir backupDir := cctx.String("backup-dir") @@ -332,7 +332,7 @@ var marketImportDatastoreCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - logging.SetLogLevel("badger", "ERROR") // nolint:errcheck + _ = logging.SetLogLevel("badger", "ERROR") backupPath := cctx.String("backup-path") diff --git a/cmd/lotus-shed/rpc.go b/cmd/lotus-shed/rpc.go index 8ef799129..42b99c664 100644 --- a/cmd/lotus-shed/rpc.go +++ b/cmd/lotus-shed/rpc.go @@ -67,7 +67,7 @@ var rpcCmd = &cli.Command{ cs := readline.NewCancelableStdin(afmt.Stdin) go func() { <-ctx.Done() - cs.Close() // nolint:errcheck + _ = cs.Close() }() send := func(method, params string) error { @@ -148,9 +148,8 @@ var rpcCmd = &cli.Command{ if err == readline.ErrInterrupt { if len(line) == 0 { break - } else { - continue } + continue } else if err == io.EOF { break } diff --git a/cmd/lotus-shed/state-stats.go b/cmd/lotus-shed/state-stats.go index 4eb00f981..59e0d7a16 100644 --- a/cmd/lotus-shed/state-stats.go +++ b/cmd/lotus-shed/state-stats.go @@ -723,7 +723,7 @@ to reduce the number of decode operations performed by caching the decoded objec go func() { // error is check later - eg.Wait() //nolint:errcheck + _ = eg.Wait() close(results) }() diff --git a/conformance/chaos/actor.go b/conformance/chaos/actor.go index 3a8b2b50a..125e3a434 100644 --- a/conformance/chaos/actor.go +++ b/conformance/chaos/actor.go @@ -274,9 +274,8 @@ type AbortWithArgs struct { func (a Actor) AbortWith(rt runtime2.Runtime, args *AbortWithArgs) *abi.EmptyValue { if args.Uncontrolled { // uncontrolled abort: directly panic panic(args.Message) - } else { - rt.Abortf(args.Code, args.Message) } + rt.Abortf(args.Code, args.Message) return nil } diff --git a/curiosrc/market/lmrpc/lmrpc.go b/curiosrc/market/lmrpc/lmrpc.go index 955872b97..d50bf82c4 100644 --- a/curiosrc/market/lmrpc/lmrpc.go +++ b/curiosrc/market/lmrpc/lmrpc.go @@ -390,9 +390,8 @@ func ServeCurioMarketRPC(db *harmonydb.DB, full api.FullNode, maddr address.Addr } if !taskResult { return api.SectorOffset{}, xerrors.Errorf("park-piece task failed: %s", taskError) - } else { - return api.SectorOffset{}, xerrors.Errorf("park task succeeded but piece is not marked as complete") } + return api.SectorOffset{}, xerrors.Errorf("park task succeeded but piece is not marked as complete") } } diff --git a/curiosrc/window/compute_do.go b/curiosrc/window/compute_do.go index 2c861ad3d..fcde14d82 100644 --- a/curiosrc/window/compute_do.go +++ b/curiosrc/window/compute_do.go @@ -202,7 +202,7 @@ func (t *WdPostTask) DoPartition(ctx context.Context, ts *types.TipSet, maddr ad Proofs: postOut, ChallengedSectors: sinfos, Prover: abi.ActorID(mid), - }); err != nil { + }); err != nil { // revive:disable-line:empty-block /*log.Errorw("window post verification failed", "post", postOut, "error", err) time.Sleep(5 * time.Second) continue todo retry loop */ @@ -337,7 +337,7 @@ func (t *WdPostTask) sectorsForProof(ctx context.Context, maddr address.Address, } func (t *WdPostTask) generateWindowPoSt(ctx context.Context, ppt abi.RegisteredPoStProof, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorID, error) { - var retErr error = nil + var retErr error randomness[31] &= 0x3f out := make([]proof.PoStProof, 0) diff --git a/curiosrc/winning/winning_task.go b/curiosrc/winning/winning_task.go index 064696727..920a73394 100644 --- a/curiosrc/winning/winning_task.go +++ b/curiosrc/winning/winning_task.go @@ -667,7 +667,7 @@ func (t *WinPostTask) computeTicket(ctx context.Context, maddr address.Address, func randTimeOffset(width time.Duration) time.Duration { buf := make([]byte, 8) - rand.Reader.Read(buf) //nolint:errcheck + _, _ = rand.Reader.Read(buf) val := time.Duration(binary.BigEndian.Uint64(buf) % uint64(width)) return val - (width / 2) diff --git a/gateway/proxy_eth.go b/gateway/proxy_eth.go index b3afaf36e..218cc189d 100644 --- a/gateway/proxy_eth.go +++ b/gateway/proxy_eth.go @@ -90,7 +90,7 @@ func (gw *Node) checkEthBlockParam(ctx context.Context, blkParam ethtypes.EthBlo return err } - var num ethtypes.EthUint64 = 0 + var num ethtypes.EthUint64 if blkParam.PredefinedBlock != nil { if *blkParam.PredefinedBlock == "earliest" { return fmt.Errorf("block param \"earliest\" is not supported") diff --git a/gen/bundle/bundle.go b/gen/bundle/bundle.go index f57ced15b..64c13ec32 100644 --- a/gen/bundle/bundle.go +++ b/gen/bundle/bundle.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/lotus/build" ) -var tmpl *template.Template = template.Must(template.New("actor-metadata").Parse(` +var tmpl = template.Must(template.New("actor-metadata").Parse(` // WARNING: This file has automatically been generated package build diff --git a/itests/eth_filter_test.go b/itests/eth_filter_test.go index d77a0ce14..114a4c255 100644 --- a/itests/eth_filter_test.go +++ b/itests/eth_filter_test.go @@ -579,7 +579,7 @@ func TestTxReceiptBloom(t *testing.T) { kit.MockProofs(), kit.ThroughRPC()) ens.InterconnectAll().BeginMining(blockTime) - logging.SetLogLevel("fullnode", "DEBUG") + _ = logging.SetLogLevel("fullnode", "DEBUG") ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() diff --git a/itests/gas_estimation_test.go b/itests/gas_estimation_test.go index 24013c885..1f3372afe 100644 --- a/itests/gas_estimation_test.go +++ b/itests/gas_estimation_test.go @@ -125,7 +125,7 @@ func TestEstimateInclusion(t *testing.T) { // Mutate the last byte to get a new address of the same length. toBytes := msg.To.Bytes() - toBytes[len(toBytes)-1] += 1 //nolint:golint + toBytes[len(toBytes)-1] += 1 // revive:disable-line:increment-decrement newAddr, err := address.NewFromBytes(toBytes) require.NoError(t, err) @@ -158,7 +158,7 @@ func TestEstimateInclusion(t *testing.T) { msg.Nonce = 2 msg.To = msg.From - msg.GasLimit -= 1 //nolint:golint + msg.GasLimit -= 1 // revive:disable-line:increment-decrement smsg, err = client.WalletSignMessage(ctx, client.DefaultKey.Address, msg) require.NoError(t, err) diff --git a/itests/harmonytask_test.go b/itests/harmonytask_test.go index 95a3db875..94024e3e1 100644 --- a/itests/harmonytask_test.go +++ b/itests/harmonytask_test.go @@ -32,7 +32,7 @@ func withDbSetup(t *testing.T, f func(*kit.TestMiner)) { kit.MockProofs(), kit.WithSectorIndexDB(), ) - logging.SetLogLevel("harmonytask", "debug") + _ = logging.SetLogLevel("harmonytask", "debug") f(miner) } diff --git a/itests/kit/client.go b/itests/kit/client.go index f7e465760..20ccb73b4 100644 --- a/itests/kit/client.go +++ b/itests/kit/client.go @@ -141,7 +141,7 @@ func createRandomFile(rseed, size int) ([]byte, string, error) { size = 1600 } data := make([]byte, size) - rand.New(rand.NewSource(int64(rseed))).Read(data) + _, _ = rand.New(rand.NewSource(int64(rseed))).Read(data) dir, err := os.MkdirTemp(os.TempDir(), "test-make-deal-") if err != nil { diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index 03a36dc45..d635f98d4 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -709,9 +709,9 @@ func (n *Ensemble) Start() *Ensemble { var mineBlock = make(chan lotusminer.MineReq) - copy := *m.FullNode - copy.FullNode = modules.MakeUuidWrapper(copy.FullNode) - m.FullNode = © + minerCopy := *m.FullNode + minerCopy.FullNode = modules.MakeUuidWrapper(minerCopy.FullNode) + m.FullNode = &minerCopy opts := []node.Option{ node.StorageMiner(&m.StorageMiner, cfg.Subsystems), diff --git a/itests/splitstore_test.go b/itests/splitstore_test.go index ea59faf2a..ff2a60a3e 100644 --- a/itests/splitstore_test.go +++ b/itests/splitstore_test.go @@ -413,9 +413,8 @@ func (g *Garbager) Exists(ctx context.Context, c cid.Cid) bool { } else if err != nil { g.t.Fatalf("ChainReadObj failure on existence check: %s", err) return false // unreachable - } else { - return true } + return true } func (g *Garbager) newPeerID(ctx context.Context) abi.ChainEpoch { diff --git a/lib/ulimit/ulimit_test.go b/lib/ulimit/ulimit_test.go index 071c6013c..ad20feb1d 100644 --- a/lib/ulimit/ulimit_test.go +++ b/lib/ulimit/ulimit_test.go @@ -46,8 +46,8 @@ func TestManageInvalidNFds(t *testing.T) { t.Logf("setting ulimit to %d, max %d, cur %d", value, rlimit.Max, rlimit.Cur) - if changed, new, err := ManageFdLimit(); err == nil { - t.Errorf("ManageFdLimit should return an error: changed %t, new: %d", changed, new) + if changed, isNew, err := ManageFdLimit(); err == nil { + t.Errorf("ManageFdLimit should return an error: changed %t, new: %d", changed, isNew) } else if err != nil { flag := strings.Contains(err.Error(), "failed to raise ulimit to LOTUS_FD_MAX") diff --git a/markets/dagstore/miner_api.go b/markets/dagstore/miner_api.go index 8a12097d5..5024bfbb2 100644 --- a/markets/dagstore/miner_api.go +++ b/markets/dagstore/miner_api.go @@ -201,7 +201,7 @@ func (m *minerAPI) GetUnpaddedCARSize(ctx context.Context, pieceCid cid.Cid) (ui return 0, xerrors.Errorf("no storage deals found for piece %s", pieceCid) } - len := pieceInfo.Deals[0].Length + l := pieceInfo.Deals[0].Length - return uint64(len), nil + return uint64(l), nil } diff --git a/markets/dagstore/miner_api_test.go b/markets/dagstore/miner_api_test.go index 08135b3a5..d13b098fc 100644 --- a/markets/dagstore/miner_api_test.go +++ b/markets/dagstore/miner_api_test.go @@ -129,9 +129,9 @@ func TestLotusAccessorGetUnpaddedCARSize(t *testing.T) { // Check that the data length is correct //stm: @MARKET_DAGSTORE_GET_UNPADDED_CAR_SIZE_001 - len, err := api.GetUnpaddedCARSize(ctx, cid1) + l, err := api.GetUnpaddedCARSize(ctx, cid1) require.NoError(t, err) - require.EqualValues(t, 10, len) + require.EqualValues(t, 10, l) } func TestThrottle(t *testing.T) { diff --git a/miner/miner.go b/miner/miner.go index d11e9d4aa..4f27c53db 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -53,7 +53,7 @@ type waitFunc func(ctx context.Context, baseTime uint64) (func(bool, abi.ChainEp func randTimeOffset(width time.Duration) time.Duration { buf := make([]byte, 8) - rand.Reader.Read(buf) //nolint:errcheck + _, _ = rand.Reader.Read(buf) val := time.Duration(binary.BigEndian.Uint64(buf) % uint64(width)) return val - (width / 2) diff --git a/node/health.go b/node/health.go index 1be11921c..90ba38378 100644 --- a/node/health.go +++ b/node/health.go @@ -48,7 +48,7 @@ func NewLiveHandler(api lapi.FullNode) *HealthHandler { var ( countdown int32 headCh <-chan []*lapi.HeadChange - backoff time.Duration = minbackoff + backoff = minbackoff err error ) minutely := time.NewTicker(time.Minute) @@ -66,10 +66,9 @@ func NewLiveHandler(api lapi.FullNode) *HealthHandler { } backoff = nextbackoff continue - } else { - healthlog.Infof("started ChainNotify channel") - backoff = minbackoff } + healthlog.Infof("started ChainNotify channel") + backoff = minbackoff } select { case <-minutely.C: diff --git a/node/impl/full/chain.go b/node/impl/full/chain.go index 1d6b8e566..ce6779780 100644 --- a/node/impl/full/chain.go +++ b/node/impl/full/chain.go @@ -644,8 +644,8 @@ func (a *ChainAPI) ChainExport(ctx context.Context, nroots abi.ChainEpoch, skipo bw := bufio.NewWriterSize(w, 1<<20) err := a.Chain.Export(ctx, ts, nroots, skipoldmsgs, bw) - bw.Flush() //nolint:errcheck // it is a write to a pipe - w.CloseWithError(err) //nolint:errcheck // it is a pipe + _ = bw.Flush() // it is a write to a pipe + _ = w.CloseWithError(err) // it is a pipe }() go func() { diff --git a/node/impl/full/eth_utils.go b/node/impl/full/eth_utils.go index 1d7bfac5a..76e891006 100644 --- a/node/impl/full/eth_utils.go +++ b/node/impl/full/eth_utils.go @@ -92,9 +92,8 @@ func getTipsetByEthBlockNumberOrHash(ctx context.Context, chain *store.ChainStor return nil, fmt.Errorf("cannot get parent tipset") } return parent, nil - } else { - return nil, fmt.Errorf("unknown predefined block %s", *predefined) } + return nil, fmt.Errorf("unknown predefined block %s", *predefined) } if blkParam.BlockNumber != nil { @@ -298,7 +297,7 @@ func executeTipset(ctx context.Context, ts *types.TipSet, cs *store.ChainStore, const errorFunctionSelector = "\x08\xc3\x79\xa0" // Error(string) const panicFunctionSelector = "\x4e\x48\x7b\x71" // Panic(uint256) // Eth ABI (solidity) panic codes. -var panicErrorCodes map[uint64]string = map[uint64]string{ +var panicErrorCodes = map[uint64]string{ 0x00: "Panic()", 0x01: "Assert()", 0x11: "ArithmeticOverflow()", @@ -398,19 +397,19 @@ func lookupEthAddress(addr address.Address, st *state.StateTree) (ethtypes.EthAd } // Lookup on the target actor and try to get an f410 address. - if actor, err := st.GetActor(idAddr); errors.Is(err, types.ErrActorNotFound) { - // Not found -> use a masked ID address - } else if err != nil { - // Any other error -> fail. - return ethtypes.EthAddress{}, err - } else if actor.Address == nil { - // No delegated address -> use masked ID address. - } else if ethAddr, err := ethtypes.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() { - // Conversable into an eth address, use it. - return ethAddr, nil - } + if actor, err := st.GetActor(idAddr); !errors.Is(err, types.ErrActorNotFound) { + if err != nil { + // Any other error -> fail. + return ethtypes.EthAddress{}, err + } + if actor.Address != nil { + if ethAddr, err := ethtypes.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() { + // Conversable into an eth address, use it. + return ethAddr, nil + } + } // else no delegated address -> use masked ID address. + } // else not found -> use a masked ID address - // Otherwise, use the masked address. return ethtypes.EthAddressFromFilecoinAddress(idAddr) } @@ -456,9 +455,9 @@ func ethTxHashFromSignedMessage(smsg *types.SignedMessage) (ethtypes.EthHash, er return tx.TxHash() } else if smsg.Signature.Type == crypto.SigTypeSecp256k1 { return ethtypes.EthHashFromCid(smsg.Cid()) - } else { // BLS message - return ethtypes.EthHashFromCid(smsg.Message.Cid()) } + // else BLS message + return ethtypes.EthHashFromCid(smsg.Message.Cid()) } func newEthTxFromSignedMessage(smsg *types.SignedMessage, st *state.StateTree) (ethtypes.EthTx, error) { @@ -817,8 +816,8 @@ func encodeAsABIHelper(param1 uint64, param2 uint64, data []byte) []byte { if len(data)%EVM_WORD_SIZE != 0 { totalWords++ } - len := totalWords * EVM_WORD_SIZE - buf := make([]byte, len) + l := totalWords * EVM_WORD_SIZE + buf := make([]byte, l) offset := 0 // Below, we use copy instead of "appending" to preserve all the zero padding. for _, arg := range staticArgs { diff --git a/node/impl/full/state.go b/node/impl/full/state.go index ae65ca0ed..ff46270b4 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -965,9 +965,8 @@ func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Addres return a.stateComputeDataCIDv1(ctx, maddr, sectorType, deals, tsk) } else if nv < network.Version21 { return a.stateComputeDataCIDv2(ctx, maddr, sectorType, deals, tsk) - } else { - return a.stateComputeDataCIDv3(ctx, maddr, sectorType, deals, tsk) } + return a.stateComputeDataCIDv3(ctx, maddr, sectorType, deals, tsk) } func (a *StateAPI) stateComputeDataCIDv1(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) { diff --git a/node/modules/lp2p/pubsub.go b/node/modules/lp2p/pubsub.go index 2b3efce6c..408ab17a6 100644 --- a/node/modules/lp2p/pubsub.go +++ b/node/modules/lp2p/pubsub.go @@ -594,7 +594,7 @@ func (trw *tracerWrapper) Trace(evt *pubsub_pb.TraceEvent) { msgsRPC := evt.GetRecvRPC().GetMeta().GetMessages() // check if any of the messages we are sending belong to a trackable topic - var validTopic bool = false + var validTopic = false for _, topic := range msgsRPC { if trw.traceMessage(topic.GetTopic()) { validTopic = true @@ -602,7 +602,7 @@ func (trw *tracerWrapper) Trace(evt *pubsub_pb.TraceEvent) { } } // track if the Iwant / Ihave messages are from a valid Topic - var validIhave bool = false + var validIhave = false for _, msgs := range ihave { if trw.traceMessage(msgs.GetTopic()) { validIhave = true @@ -630,7 +630,7 @@ func (trw *tracerWrapper) Trace(evt *pubsub_pb.TraceEvent) { msgsRPC := evt.GetSendRPC().GetMeta().GetMessages() // check if any of the messages we are sending belong to a trackable topic - var validTopic bool = false + var validTopic = false for _, topic := range msgsRPC { if trw.traceMessage(topic.GetTopic()) { validTopic = true @@ -638,7 +638,7 @@ func (trw *tracerWrapper) Trace(evt *pubsub_pb.TraceEvent) { } } // track if the Iwant / Ihave messages are from a valid Topic - var validIhave bool = false + var validIhave = false for _, msgs := range ihave { if trw.traceMessage(msgs.GetTopic()) { validIhave = true diff --git a/node/modules/lp2p/rcmgr.go b/node/modules/lp2p/rcmgr.go index f2b284986..ae478acde 100644 --- a/node/modules/lp2p/rcmgr.go +++ b/node/modules/lp2p/rcmgr.go @@ -38,7 +38,7 @@ func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo) log.Info("libp2p resource manager is enabled") // enable debug logs for rcmgr - logging.SetLogLevel("rcmgr", "debug") + _ = logging.SetLogLevel("rcmgr", "debug") // Adjust default defaultLimits // - give it more memory, up to 4G, min of 1G diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index 6cac14c01..ec35f8f30 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -288,7 +288,7 @@ func (fsr *FsRepo) Init(t RepoType) error { } log.Infof("Initializing repo at '%s'", fsr.path) - err = os.MkdirAll(fsr.path, 0755) //nolint: gosec + err = os.MkdirAll(fsr.path, 0755) if err != nil && !os.IsExist(err) { return err } diff --git a/storage/paths/index_test.go b/storage/paths/index_test.go index 8793b8814..328717bb4 100644 --- a/storage/paths/index_test.go +++ b/storage/paths/index_test.go @@ -15,7 +15,7 @@ import ( ) func init() { - logging.SetLogLevel("stores", "DEBUG") + _ = logging.SetLogLevel("stores", "DEBUG") } func newTestStorage() storiface.StorageInfo { diff --git a/storage/sealer/ffiwrapper/sealer_test.go b/storage/sealer/ffiwrapper/sealer_test.go index 59821e795..250d057e3 100644 --- a/storage/sealer/ffiwrapper/sealer_test.go +++ b/storage/sealer/ffiwrapper/sealer_test.go @@ -37,7 +37,7 @@ import ( ) func init() { - logging.SetLogLevel("*", "DEBUG") //nolint: errcheck + _ = logging.SetLogLevel("*", "DEBUG") } var sealProofType = abi.RegisteredSealProof_StackedDrg2KiBV1 diff --git a/storage/sealer/manager_post.go b/storage/sealer/manager_post.go index 27a71ef8c..a1020d4b6 100644 --- a/storage/sealer/manager_post.go +++ b/storage/sealer/manager_post.go @@ -108,7 +108,7 @@ func dedupeSectorInfo(sectorInfo []proof.ExtendedSectorInfo) []proof.ExtendedSec } func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, ppt abi.RegisteredPoStProof, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorID, error) { - var retErr error = nil + var retErr error randomness[31] &= 0x3f out := make([]proof.PoStProof, 0) diff --git a/storage/sealer/sched_post.go b/storage/sealer/sched_post.go index c6bd81829..4b9769d68 100644 --- a/storage/sealer/sched_post.go +++ b/storage/sealer/sched_post.go @@ -56,7 +56,7 @@ func (ps *poStScheduler) MaybeAddWorker(wid storiface.WorkerID, tasks map[sealta func (ps *poStScheduler) delWorker(wid storiface.WorkerID) *WorkerHandle { ps.lk.Lock() defer ps.lk.Unlock() - var w *WorkerHandle = nil + var w *WorkerHandle if wh, ok := ps.workers[wid]; ok { w = wh delete(ps.workers, wid) diff --git a/storage/wdpost/wdpost_changehandler_test.go b/storage/wdpost/wdpost_changehandler_test.go index 44d0dfe6d..c2d993bee 100644 --- a/storage/wdpost/wdpost_changehandler_test.go +++ b/storage/wdpost/wdpost_changehandler_test.go @@ -84,10 +84,10 @@ func (m *mockAPI) setDeadline(di *dline.Info) { } func (m *mockAPI) getDeadline(currentEpoch abi.ChainEpoch) *dline.Info { - close := minertypes.WPoStChallengeWindow - 1 + closeEpoch := minertypes.WPoStChallengeWindow - 1 dlIdx := uint64(0) - for close < currentEpoch { - close += minertypes.WPoStChallengeWindow + for closeEpoch < currentEpoch { + closeEpoch += minertypes.WPoStChallengeWindow dlIdx++ } return NewDeadlineInfo(0, dlIdx, currentEpoch) diff --git a/storage/wdpost/wdpost_run_faults.go b/storage/wdpost/wdpost_run_faults.go index 3a41cc4cc..250be0c3a 100644 --- a/storage/wdpost/wdpost_run_faults.go +++ b/storage/wdpost/wdpost_run_faults.go @@ -23,7 +23,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -var RecoveringSectorLimit uint64 = 0 +var RecoveringSectorLimit uint64 func init() { if rcl := os.Getenv("LOTUS_RECOVERING_SECTOR_LIMIT"); rcl != "" {