mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
coreapi unixfs: layout/chunker options
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@ee22ac4385 This commit was moved from ipfs/boxo@f858a5213f
This commit is contained in:
parent
9e57389b04
commit
82ef32dcaf
@ -4,6 +4,13 @@ import (
|
||||
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
|
||||
)
|
||||
|
||||
type Layout int
|
||||
|
||||
const (
|
||||
BalancedLayout Layout = iota
|
||||
TrickleLeyout
|
||||
)
|
||||
|
||||
type UnixfsAddSettings struct {
|
||||
CidVersion int
|
||||
MhType uint64
|
||||
@ -11,6 +18,9 @@ type UnixfsAddSettings struct {
|
||||
InlineLimit int
|
||||
RawLeaves bool
|
||||
RawLeavesSet bool
|
||||
|
||||
Chunker string
|
||||
Layout Layout
|
||||
}
|
||||
|
||||
type UnixfsAddOption func(*UnixfsAddSettings) error
|
||||
@ -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 {
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user