Skip to content

Commit

Permalink
chore: lint: enable type godoc linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jul 19, 2024
1 parent 9e6e781 commit 526d1ff
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ issues:
- "^blank-imports: a blank import should be only in a main or test package, or have a comment justifying it"
- "^dot-imports: should not use dot imports"
- "^exported: (func|type) name will be used as [^\\s]+ by other packages, and that stutters; consider calling this \\w+"
- "^exported: comment on exported (const|type|var) [^\\s]+ should be of the form \"\\w+ ...\""
- "^exported: comment on exported (const|var) [^\\s]+ should be of the form \"\\w+ ...\""
- "^exported: exported (const|function|method|type|var) [^\\s]+ should have comment (\\(or a comment on this block\\) )?or be unexported"
- "^indent-error-flow: if block ends with a return statement, so drop this else and outdent its block \\(move short variable declaration to its own line if necessary\\)"
- "^package-comments: package comment should be of the form \"Package \\w+ ...\""
Expand Down
8 changes: 3 additions & 5 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ type FullNode interface {
F3GetPowerTable(ctx context.Context, tsk types.TipSetKey) (gpbft.PowerEntries, error) //perm:read
}

// reverse interface to the client, called after EthSubscribe
// EthSubscriber is the reverse interface to the client, called after EthSubscribe
type EthSubscriber interface {
// note: the parameter is ethtypes.EthSubscriptionResponse serialized as json object
EthSubscription(ctx context.Context, r jsonrpc.RawParams) error // rpc_method:eth_subscription notify:true
Expand Down Expand Up @@ -917,11 +917,9 @@ type MsgGasCost struct {
TotalCost abi.TokenAmount
}

// BlsMessages[x].cid = Cids[x]
// SecpkMessages[y].cid = Cids[BlsMessages.length + y]
type BlockMessages struct {
BlsMessages []*types.Message
SecpkMessages []*types.SignedMessage
BlsMessages []*types.Message // BlsMessages [x].cid = Cids[x]
SecpkMessages []*types.SignedMessage // SecpkMessages [y].cid = Cids[BlsMessages.length + y]

Cids []cid.Cid
}
Expand Down
4 changes: 4 additions & 0 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,13 @@ type SectorPiece struct {
DealInfo *piece.PieceDealInfo
}

// PieceDealInfo is deprecated
//
// DEPRECATED: Use piece.PieceDealInfo instead
type PieceDealInfo = piece.PieceDealInfo

// DealSchedule is deprecated
//
// DEPRECATED: Use piece.DealSchedule instead
type DealSchedule = piece.DealSchedule

Expand Down
1 change: 1 addition & 0 deletions blockstore/badger/blockstore_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

// TODO: move this to go-ipfs-blockstore.

type Suite struct {
NewBlockstore func(tb testing.TB) (bs blockstore.BasicBlockstore, path string)
OpenBlockstore func(tb testing.TB, path string) (bs blockstore.BasicBlockstore, err error)
Expand Down
4 changes: 2 additions & 2 deletions chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch)
return market14.DealDurationBounds(pieceSize)
}

// SetWPoStChallengeWindow sets the challenge window and scales the proving period to match (such that
// there are always 48 challenge windows in a proving period).
// SetWPoStChallengeWindow sets the challenge window and scales the proving period to match (such
// that there are always 48 challenge windows in a proving period).
func SetWPoStChallengeWindow(period abi.ChainEpoch) {

miner0.WPoStChallengeWindow = period
Expand Down
6 changes: 3 additions & 3 deletions chain/actors/policy/policy.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
{{end}}
}

// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
func GetPreCommitChallengeDelay() abi.ChainEpoch {
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
return miner{{.latestVersion}}.PreCommitChallengeDelay
}

Expand Down Expand Up @@ -200,8 +200,8 @@ func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch)
return market{{.latestVersion}}.DealDurationBounds(pieceSize)
}

// Sets the challenge window and scales the proving period to match (such that
// there are always 48 challenge windows in a proving period).
// SetWPoStChallengeWindow sets the challenge window and scales the proving period to match (such
// that there are always 48 challenge windows in a proving period).
func SetWPoStChallengeWindow(period abi.ChainEpoch) {
{{range .versions}}
miner{{.}}.WPoStChallengeWindow = period
Expand Down
2 changes: 1 addition & 1 deletion chain/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

var log = logging.Logger("events")

// HeightHandler `curH`-`ts.Height` = `confidence`
type (
// HeightHandler `curH`-`ts.Height` = `confidence`
HeightHandler func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error
RevertHandler func(ctx context.Context, ts *types.TipSet) error
)
Expand Down
11 changes: 4 additions & 7 deletions chain/exchange/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const (
streamReadDeadline = 10 * time.Second
)

// FIXME: Rename. Make private.
type Request struct {
type Request struct { // FIXME: Rename. Make private.
// List of ordered CIDs comprising a `TipSetKey` from where to start
// fetching backwards.
// FIXME: Consider using `TipSetKey` now (introduced after the creation
Expand Down Expand Up @@ -89,8 +88,7 @@ func parseOptions(optfield uint64) *parsedOptions {
}
}

// FIXME: Rename. Make private.
type Response struct {
type Response struct { // FIXME: Rename. Make private.
Status status
// String that complements the error status when converting to an
// internal error (see `statusToError()`).
Expand Down Expand Up @@ -134,15 +132,14 @@ func (res *Response) statusToError() error {
}
}

// FIXME: Rename.
type BSTipSet struct {
type BSTipSet struct { // FIXME: Rename.
// List of blocks belonging to a single tipset to which the
// `CompactedMessages` are linked.
Blocks []*types.BlockHeader
Messages *CompactedMessages
}

// All messages of a single tipset compacted together instead
// CompactedMessages has all messages of a single tipset compacted together instead
// of grouped by block to save space, since there are normally
// many repeated messages per tipset in different blocks.
//
Expand Down
2 changes: 1 addition & 1 deletion chain/exchange/protocol_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
types "github.com/filecoin-project/lotus/chain/types"
)

// Type used for encoding/decoding compacted messages. This is a ustom type as we need custom limits.
// CompactedMessagesCBOR is used for encoding/decoding compacted messages. This is a ustom type as we need custom limits.
// - Max messages is 150,000 as that's 15 times the max block size (in messages). It needs to be
// large enough to cover a full tipset full of full blocks.
type CompactedMessagesCBOR struct {
Expand Down
2 changes: 1 addition & 1 deletion chain/index/msgindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
CoalesceMergeInterval = time.Second
)

// chain store interface; we could use store.ChainStore directly,
// ChainStore interface; we could use store.ChainStore directly,
// but this simplifies unit testing.
type ChainStore interface {
SubscribeHeadChanges(f store.ReorgNotifee)
Expand Down
2 changes: 1 addition & 1 deletion chain/market/fundmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

var log = logging.Logger("market_adapter")

// API is the fx dependencies need to run a fund manager
// FundManagerAPI is the fx dependencies need to run a fund manager
type FundManagerAPI struct {
fx.In

Expand Down
4 changes: 2 additions & 2 deletions chain/types/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var ErrActorNotFound = errors.New("actor not found")

// Actor State for state tree version up to 4
// ActorV4 is Actor State for state tree version up to 4
type ActorV4 struct {
// Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`.
Code cid.Cid
Expand All @@ -19,7 +19,7 @@ type ActorV4 struct {
Balance BigInt
}

// Actor State for state tree version 5
// ActorV5 is Actor State for state tree version 5
type ActorV5 struct {
// Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`.
Code cid.Cid
Expand Down
8 changes: 4 additions & 4 deletions chain/types/ethtypes/eth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func (h EthFilterID) String() string {
return (EthHash)(h).String()
}

// An opaque identifier generated by the Lotus node to refer to an active subscription.
// EthSubscriptionID is an opaque identifier generated by the Lotus node to refer to an active subscription.
type EthSubscriptionID EthHash

func (h EthSubscriptionID) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -626,7 +626,7 @@ type EthFilterSpec struct {
BlockHash *EthHash `json:"blockHash,omitempty"`
}

// EthAddressSpec represents a list of addresses.
// EthAddressList represents a list of addresses.
// The JSON decoding must treat a string as equivalent to an array with one value, for example
// "0x8888f1f195afa192cfee86069858" must be decoded as [ "0x8888f1f195afa192cfee86069858" ]
type EthAddressList []EthAddress
Expand All @@ -653,7 +653,7 @@ func (e *EthAddressList) UnmarshalJSON(b []byte) error {
return nil
}

// TopicSpec represents a specification for matching by topic. An empty spec means all topics
// EthTopicSpec represents a specification for matching by topic. An empty spec means all topics
// will be matched. Otherwise topics are matched conjunctively in the first dimension of the
// slice and disjunctively in the second dimension. Topics are matched in order.
// An event log with topics [A, B] will be matched by the following topic specs:
Expand Down Expand Up @@ -693,7 +693,7 @@ func (e *EthHashList) UnmarshalJSON(b []byte) error {
return nil
}

// FilterResult represents the response from executing a filter: a list of block hashes, a list of transaction hashes
// EthFilterResult represents the response from executing a filter: a list of block hashes, a list of transaction hashes
// or a list of logs
// This is a union type. Only one field will be populated.
// The JSON encoding must produce an array of the populated field.
Expand Down
3 changes: 1 addition & 2 deletions chain/types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ type StateRoot struct {
Info cid.Cid
}

// TODO: version this.
type StateInfo0 struct{}
type StateInfo0 struct{} // TODO: version this.
2 changes: 1 addition & 1 deletion gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewRateLimiterHandler(handler http.Handler, rateLimit int64) *RateLimiterHa
}
}

// Adds a rate limiter to the request context for per-connection rate limiting
// RateLimiterHandler adds a rate limiter to the request context for per-connection rate limiting
type RateLimiterHandler struct {
handler http.Handler
limiter *rate.Limiter
Expand Down
2 changes: 1 addition & 1 deletion itests/kit/node_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (tm *TestMiner) SectorsListNonGenesis(ctx context.Context) ([]abi.SectorNum
return l[tm.PresealSectors:], nil
}

// comes from https://github.com/filecoin-project/lotus/blob/8ba4355cabd25e5f65261aaa561ff676321ffbd8/storage/sealer/manager.go#L1226
// SchedInfo comes from https://github.com/filecoin-project/lotus/blob/8ba4355cabd25e5f65261aaa561ff676321ffbd8/storage/sealer/manager.go#L1226
// todo: have this defined in one place
type SchedInfo struct {
CallToWork struct{}
Expand Down
3 changes: 2 additions & 1 deletion node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ type Splitstore struct {
HotstoreMaxSpaceSafetyBuffer uint64
}

// // Full Node
// Full Node

type Wallet struct {
RemoteBackend string
EnableLedger bool
Expand Down
2 changes: 1 addition & 1 deletion paychmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type stateManagerAPI interface {
Call(ctx context.Context, msg *types.Message, ts *types.TipSet) (*api.InvocResult, error)
}

// paychAPI defines the API methods needed by the payment channel manager
// PaychAPI defines the API methods needed by the payment channel manager
type PaychAPI interface {
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
Expand Down
1 change: 1 addition & 0 deletions storage/pipeline/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
// TODO: For now we handle this by halting state execution, when we get jsonrpc reconnecting
//
// We should implement some wait-for-api logic

type ErrApi struct{ error }

type ErrNoDeals struct{ error }
Expand Down
2 changes: 1 addition & 1 deletion storage/pipeline/fsm_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (evt SectorCommitted) apply(state *SectorInfo) {
state.Proof = evt.Proof
}

// like SectorCommitted, but finalizes before sending the proof to the chain
// SectorProofReady is like SectorCommitted, but finalizes before sending the proof to the chain
type SectorProofReady struct {
Proof []byte
}
Expand Down
1 change: 1 addition & 0 deletions storage/pipeline/lib/nullreader/nullreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (m NullReader) NullBytes() int64 {
}

// TODO: extract this to someplace where it can be shared with lotus

type Reader struct{}

func (Reader) Read(out []byte) (int, error) {
Expand Down
2 changes: 1 addition & 1 deletion storage/pipeline/piece/piece_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)

// DealInfo is a tuple of deal identity and its schedule
// PieceDealInfo is a tuple of deal identity and its schedule
type PieceDealInfo struct {
// "Old" builtin-market deal info
PublishCid *cid.Cid
Expand Down
1 change: 1 addition & 0 deletions storage/sealer/storiface/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func (sd *SectorLocation) HttpHeaders() http.Header {
}

// note: we can't use http.Header as that's backed by a go map, which is all kinds of messy

type SecDataHttpHeader struct {
Key string
Value string
Expand Down
1 change: 1 addition & 0 deletions storage/sealer/worker_calltracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (wt *workerCallTracker) unfinished() ([]Call, error) {
}

// Ideally this would be a tag on the struct field telling cbor-gen to enforce higher max-len

type ManyBytes struct {
b []byte
}
Expand Down
1 change: 1 addition & 0 deletions storage/sealer/worker_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type WorkerConfig struct {
}

// used do provide custom proofs impl (mostly used in testing)

type ExecutorFunc func(w *LocalWorker) (storiface.Storage, error)
type EnvFunc func(string) (string, bool)

Expand Down

0 comments on commit 526d1ff

Please sign in to comment.