Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 3, 2024
1 parent 10a63c0 commit 0938b74
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 6 additions & 0 deletions ipfs/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,32 @@ type (
MaxLinks int
BlockSize int64
}
// A UnixFSOption sets options for the UnixFS importer
UnixFSOption func(*unixFSOptions)
)

// UnixFSWithCIDBuilder sets the CID builder for the UnixFS importer
func UnixFSWithCIDBuilder(b cid.Builder) UnixFSOption {
return func(u *unixFSOptions) {
u.CIDBuilder = b
}
}

// UnixFSWithRawLeaves sets the raw leaves option for the UnixFS importer
func UnixFSWithRawLeaves(b bool) UnixFSOption {
return func(u *unixFSOptions) {
u.RawLeaves = b
}
}

// UnixFSWithMaxLinks sets the maximum number of links per block for the UnixFS importer
func UnixFSWithMaxLinks(b int) UnixFSOption {
return func(u *unixFSOptions) {
u.MaxLinks = b
}
}

// UnixFSWithBlockSize sets the block size for the UnixFS importer
func UnixFSWithBlockSize(b int64) UnixFSOption {
return func(u *unixFSOptions) {
u.BlockSize = b
Expand Down Expand Up @@ -89,6 +94,7 @@ func (n *Node) DownloadUnixFile(ctx context.Context, c cid.Cid, path []string) (
return dr, err
}

// UploadUnixFile uploads a UnixFS file to IPFS
func (n *Node) UploadUnixFile(ctx context.Context, r io.Reader, opts ...UnixFSOption) (format.Node, error) {
opt := unixFSOptions{
MaxLinks: ihelpers.DefaultLinksPerBlock,
Expand Down
1 change: 1 addition & 0 deletions renterd/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func (bd *BlockDownloader) downloadWorker(ctx context.Context, n int) {
}
}

// Get returns a block by CID.
func (bd *BlockDownloader) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) {
return bd.getResponse(c, downloadPriorityHigh).block(ctx, c)
}
Expand Down
12 changes: 3 additions & 9 deletions renterd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
)

type options struct {
Bucket string
CacheSize int
Bucket string

Downloader BlockDownloader
Worker *worker.Client
Bus *bus.Client
Log *zap.Logger
}

// An Option configures a renterd store
type Option func(*options)

// WithBucket sets the bucket name.
Expand Down Expand Up @@ -46,15 +46,9 @@ func WithBus(b *bus.Client) Option {
}
}

// WithDownloader sets the block downloader.
func WithDownloader(bd BlockDownloader) Option {
return func(o *options) {
o.Downloader = bd
}
}

// WithCacheSize sets the size of the block cache.
func WithCacheSize(size int) Option {
return func(o *options) {
o.CacheSize = size
}
}
5 changes: 2 additions & 3 deletions renterd/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ func (bs *BlockStore) HashOnRead(enabled bool) {
// NewBlockStore creates a new blockstore backed by a renterd node
func NewBlockStore(opts ...Option) (*BlockStore, error) {
options := &options{
Log: zap.NewNop(),
Bucket: "ipfs",
CacheSize: 1024, // 1GiB assuming 1MiB blocks
Log: zap.NewNop(),
Bucket: "ipfs",
}
for _, opt := range opts {
opt(options)
Expand Down

0 comments on commit 0938b74

Please sign in to comment.