coreapi unixfs: pin/local/hash-only options

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@8521907e1a

This commit was moved from ipfs/boxo@27ded0dea2
This commit is contained in:
Łukasz Magiera 2018-09-20 23:05:22 +02:00
parent 82ef32dcaf
commit ac8ff30732

View File

@ -21,6 +21,10 @@ type UnixfsAddSettings struct {
Chunker string
Layout Layout
Pin bool
OnlyHash bool
Local bool
}
type UnixfsAddOption func(*UnixfsAddSettings) error
@ -36,6 +40,10 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, error) {
Chunker: "size-262144",
Layout: BalancedLayout,
Pin: false,
OnlyHash: false,
Local: false,
}
for _, opt := range opts {
@ -94,3 +102,24 @@ func (unixfsOpts) Layout(layout Layout) UnixfsAddOption {
return nil
}
}
func (unixfsOpts) Pin(pin bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Pin = pin
return nil
}
}
func (unixfsOpts) HashOnly(hashOnly bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.OnlyHash = hashOnly
return nil
}
}
func (unixfsOpts) Local(local bool) UnixfsAddOption {
return func(settings *UnixfsAddSettings) error {
settings.Local = local
return nil
}
}