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
83ccc7e4
Commit
83ccc7e4
authored
Jan 22, 2018
by
ForrestWeston
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs for pin method impls
License: MIT Signed-off-by:
ForrestWeston
<
forrest@protocol.ai
>
parent
d3f5ee22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
pin/pin.go
pin/pin.go
+14
-0
No files found.
pin/pin.go
View file @
83ccc7e4
...
...
@@ -147,6 +147,7 @@ type Pinned struct {
Via
*
cid
.
Cid
}
// Pinned returns whether or not the given cid is pinned
func
(
p
Pinned
)
Pinned
()
bool
{
if
p
.
Mode
==
NotPinned
{
return
false
...
...
@@ -155,6 +156,7 @@ func (p Pinned) Pinned() bool {
}
}
// String Returns pin status as string
func
(
p
Pinned
)
String
()
string
{
switch
p
.
Mode
{
case
NotPinned
:
...
...
@@ -277,6 +279,8 @@ func (p *pinner) IsPinned(c *cid.Cid) (string, bool, error) {
return
p
.
isPinnedWithType
(
c
,
Any
)
}
// 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.
func
(
p
*
pinner
)
IsPinnedWithType
(
c
*
cid
.
Cid
,
mode
PinMode
)
(
string
,
bool
,
error
)
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
...
...
@@ -328,6 +332,8 @@ func (p *pinner) isPinnedWithType(c *cid.Cid, mode PinMode) (string, bool, error
return
""
,
false
,
nil
}
// CheckIfPinned Checks if a set of keys are pinned, more efficient than
// calling IsPinned for each key, returns the pinned status of cid(s)
func
(
p
*
pinner
)
CheckIfPinned
(
cids
...*
cid
.
Cid
)
([]
Pinned
,
error
)
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
...
...
@@ -393,6 +399,9 @@ func (p *pinner) CheckIfPinned(cids ...*cid.Cid) ([]Pinned, error) {
return
pinned
,
nil
}
// RemovePinWithMode is for manually editing the pin structure.
// Use with care! If used improperly, garbage collection may not
// be successful.
func
(
p
*
pinner
)
RemovePinWithMode
(
c
*
cid
.
Cid
,
mode
PinMode
)
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
...
...
@@ -486,6 +495,9 @@ func (p *pinner) RecursiveKeys() []*cid.Cid {
return
p
.
recursePin
.
Keys
()
}
// Update updates a recursive pin from one cid to another
// this is more efficient than simply pinning the new one and unpinning the
// old one
func
(
p
*
pinner
)
Update
(
ctx
context
.
Context
,
from
,
to
*
cid
.
Cid
,
unpin
bool
)
error
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
...
...
@@ -556,6 +568,8 @@ func (p *pinner) Flush() error {
return
nil
}
// InternalPins returns all cids kept pinned for the internal state of the
// pinner
func
(
p
*
pinner
)
InternalPins
()
[]
*
cid
.
Cid
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
...
...
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