@cryptotaxi247 / kubo / commits / 1841565f9

coreapi: Pin option for Object.Put

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@ca13e9b2ef673c3eb63baecc0cf840036405e214 This commit was moved from ipfs/boxo@8fa8a1e440ea9d280b5c2b717f1de35602f83f08

Łukasz Magiera committed Feb 2, 2018 at 16:28 UTC 1841565f9c1c4cb6520540543bddf4a2cef384b5
1 file changed +11
core/coreiface/options/object.go
+11
@@ -7,6 +7,7 @@ type ObjectNewSettings struct {
7 type ObjectPutSettings struct {
8 InputEnc string
9 DataType string
10 + Pin bool
11 }
12
13 type ObjectAddLinkSettings struct {
@@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
36 options := &ObjectPutSettings{
37 InputEnc: "json",
38 DataType: "text",
39 + Pin: false,
40 }
41
42 for _, opt := range opts {
@@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption {
105 }
106 }
107
108 +// WithPin is an option for Object.Put which specifies whether to pin the added
109 +// objects, default is false
110 +func (objectOpts) WithPin(pin bool) ObjectPutOption {
111 + return func(settings *ObjectPutSettings) error {
112 + settings.Pin = pin
113 + return nil
114 + }
115 +}
116 +
117 // Create is an option for Object.AddLink which specifies whether create required
118 // directories for the child
119 func (objectOpts) Create(create bool) ObjectAddLinkOption {