Skip to content

Commit

Permalink
coreapi: Pin option for Object.Put
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@ca13e9b
  • Loading branch information
magik6k committed Aug 1, 2018
1 parent 069cd0e commit 8fa8a1e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions coreiface/options/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ObjectNewSettings struct {
type ObjectPutSettings struct {
InputEnc string
DataType string
Pin bool
}

type ObjectAddLinkSettings struct {
Expand Down Expand Up @@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
options := &ObjectPutSettings{
InputEnc: "json",
DataType: "text",
Pin: false,
}

for _, opt := range opts {
Expand Down Expand Up @@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption {
}
}

// WithPin is an option for Object.Put which specifies whether to pin the added
// objects, default is false
func (objectOpts) WithPin(pin bool) ObjectPutOption {
return func(settings *ObjectPutSettings) error {
settings.Pin = pin
return nil
}
}

// Create is an option for Object.AddLink which specifies whether create required
// directories for the child
func (objectOpts) Create(create bool) ObjectAddLinkOption {
Expand Down

0 comments on commit 8fa8a1e

Please sign in to comment.