Commit 8521907e authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi unixfs: pin/local/hash-only options

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent ee22ac43
......@@ -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
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment