Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
coreapi unixfs: layout/chunker options
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Oct 3, 2018
1 parent dbdf6fd commit ee22ac4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions options/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ import (
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
)

type Layout int

const (
BalancedLayout Layout = iota
TrickleLeyout
)

type UnixfsAddSettings struct {
CidVersion int
MhType uint64

InlineLimit int
RawLeaves bool
RawLeavesSet bool

Chunker string
Layout Layout
}

type UnixfsAddOption func(*UnixfsAddSettings) error
Expand All @@ -23,6 +33,9 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, error) {
InlineLimit: 0,
RawLeaves: false,
RawLeavesSet: false,

Chunker: "size-262144",
Layout: BalancedLayout,
}

for _, opt := range opts {
Expand Down Expand Up @@ -67,3 +80,17 @@ func (unixfsOpts) InlineLimit(limit int) UnixfsAddOption {
return nil
}
}

func (unixfsOpts) Chunker(chunker string) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Chunker = chunker
return nil
}
}

func (unixfsOpts) Layout(layout Layout) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Layout = layout
return nil
}
}

0 comments on commit ee22ac4

Please sign in to comment.