Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
ce57a766
Commit
ce57a766
authored
Jan 21, 2018
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interface docs for pinner
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
2140aa95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
pin/pin.go
pin/pin.go
+31
-2
No files found.
pin/pin.go
View file @
ce57a766
...
...
@@ -46,11 +46,22 @@ const (
type
PinMode
int
const
(
// Recursive pins pin the target cids along with any reachable children.
Recursive
PinMode
=
iota
// Direct pins pin just the target cid.
Direct
// Indirect pins are cids who have some ancestor pinned recursively.
Indirect
// Internal pins are cids used to keep the internal state of the pinner.
Internal
// NotPinned
NotPinned
// Any refers to any pinned cid
Any
)
...
...
@@ -82,10 +93,20 @@ func StringToPinMode(s string) (PinMode, bool) {
}
type
Pinner
interface
{
// IsPinned returns whether or not the given cid is pinned
// and an explanation of why its pinned
IsPinned
(
*
cid
.
Cid
)
(
string
,
bool
,
error
)
// IsPinnedWithType returns whether or not the given cid is pinned with the
// given pin type, as well as returning the type of pin its pinned with.
IsPinnedWithType
(
*
cid
.
Cid
,
PinMode
)
(
string
,
bool
,
error
)
Pin
(
context
.
Context
,
node
.
Node
,
bool
)
error
Unpin
(
context
.
Context
,
*
cid
.
Cid
,
bool
)
error
// Pin the given node, optionally recursively.
Pin
(
ctx
context
.
Context
,
node
node
.
Node
,
recursive
bool
)
error
// Unpin the given cid. If recursive is true, removes either a recursive or
// a direct pin. If recursive is false, only removes a direct pin.
Unpin
(
ctx
context
.
Context
,
cid
*
cid
.
Cid
,
recursive
bool
)
error
// Update updates a recursive pin from one cid to another
// this is more efficient than simply pinning the new one and unpinning the
...
...
@@ -106,9 +127,17 @@ type Pinner interface {
// be successful.
RemovePinWithMode
(
*
cid
.
Cid
,
PinMode
)
// Flush writes the pin state to the backing datastore
Flush
()
error
// DirectKeys returns all directly pinned cids
DirectKeys
()
[]
*
cid
.
Cid
// DirectKeys returns all recursively pinned cids
RecursiveKeys
()
[]
*
cid
.
Cid
// InternalPins returns all cids kept pinned for the internal state of the
// pinner
InternalPins
()
[]
*
cid
.
Cid
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment