Skip to content

Commit

Permalink
chore: lint: fix lint errors with new linting config
Browse files Browse the repository at this point in the history
Ref: #11967
  • Loading branch information
rvagg committed May 9, 2024
1 parent d21c04b commit c90a099
Show file tree
Hide file tree
Showing 66 changed files with 128 additions and 153 deletions.
6 changes: 2 additions & 4 deletions blockstore/buffered.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
7 changes: 2 additions & 5 deletions blockstore/splitstore/splitstore_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion blockstore/splitstore/splitstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion build/builtin_actors_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ipfs/go-cid"
)

var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMetadata{{
var EmbeddedBuiltinActorsMetadata = []*BuiltinActorsMetadata{{
Network: "butterflynet",
Version: 8,

Expand Down
2 changes: 1 addition & 1 deletion build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 9 additions & 9 deletions chain/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions chain/messagepool/selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions chain/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion chain/store/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion chain/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Expand Down Expand Up @@ -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))
}
}

Expand Down
4 changes: 2 additions & 2 deletions chain/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion chain/types/ethtypes/eth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions chain/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,16 @@ 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,
From: rt.Message.Caller(),
Value: rt.Message.ValueReceived(),
},
}

rt.Message = &nmsg
}
} // else leave the rt.Message as is
} else {
return nil, aerrors.Escalate(err, "getting actor")
}
Expand Down
2 changes: 1 addition & 1 deletion cli/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cli/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

func init() {
logging.SetLogLevel("watchdog", "ERROR")
_ = logging.SetLogLevel("watchdog", "ERROR")
}
2 changes: 1 addition & 1 deletion cli/sending_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/curio/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-bench/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type Commit2In struct {
}

func main() {
logging.SetLogLevel("*", "INFO")
_ = logging.SetLogLevel("*", "INFO")

log.Info("Starting lotus-bench")

Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-bench/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-fountain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var log = logging.Logger("main")

func main() {
logging.SetLogLevel("*", "INFO")
_ = logging.SetLogLevel("*", "INFO")

log.Info("Starting fountain")

Expand Down
2 changes: 1 addition & 1 deletion cmd/lotus-health/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-miner/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Loading

0 comments on commit c90a099

Please sign in to comment.