interface docs for pinner
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jan 21, 2018 at 11:31 UTC
ce57a766876b1251b27578aa4c06c31d4deb867d
1 file changed
+31
-2
pin/pin.go
+31
-2
@@ -46,11 +46,22 @@ const (
46
type PinMode int
47
48
const (
49
+ // Recursive pins pin the target cids along with any reachable children.
50
Recursive PinMode = iota
51
+
52
+ // Direct pins pin just the target cid.
53
Direct
54
+
55
+ // Indirect pins are cids who have some ancestor pinned recursively.
56
Indirect
57
+
58
+ // Internal pins are cids used to keep the internal state of the pinner.
59
Internal
60
+
61
+ // NotPinned
62
NotPinned
63
+
64
+ // Any refers to any pinned cid
65
Any
66
)
67
@@ -82,10 +93,20 @@ func StringToPinMode(s string) (PinMode, bool) {
93
}
94
95
type Pinner interface {
96
+ // IsPinned returns whether or not the given cid is pinned
97
+ // and an explanation of why its pinned
98
IsPinned(*cid.Cid) (string, bool, error)
99
+
100
+ // IsPinnedWithType returns whether or not the given cid is pinned with the
101
+ // given pin type, as well as returning the type of pin its pinned with.
102
IsPinnedWithType(*cid.Cid, PinMode) (string, bool, error)
87
- Pin(context.Context, node.Node, bool) error
88
- Unpin(context.Context, *cid.Cid, bool) error
103
+
104
+ // Pin the given node, optionally recursively.
105
+ Pin(ctx context.Context, node node.Node, recursive bool) error
106
+
107
+ // Unpin the given cid. If recursive is true, removes either a recursive or
108
+ // a direct pin. If recursive is false, only removes a direct pin.
109
+ Unpin(ctx context.Context, cid *cid.Cid, recursive bool) error
110
111
// Update updates a recursive pin from one cid to another
112
// this is more efficient than simply pinning the new one and unpinning the
@@ -106,9 +127,17 @@ type Pinner interface {
127
// be successful.
128
RemovePinWithMode(*cid.Cid, PinMode)
129
130
+ // Flush writes the pin state to the backing datastore
131
Flush() error
132
+
133
+ // DirectKeys returns all directly pinned cids
134
DirectKeys() []*cid.Cid
135
+
136
+ // DirectKeys returns all recursively pinned cids
137
RecursiveKeys() []*cid.Cid
138
+
139
+ // InternalPins returns all cids kept pinned for the internal state of the
140
+ // pinner
141
InternalPins() []*cid.Cid
142
}
143