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-pinner
Commits
12448909
Commit
12448909
authored
7 years ago
by
Hector Sanjuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc: golint: remove stuttering in pin package
License: MIT Signed-off-by:
Hector Sanjuan
<
hector@protocol.ai
>
parent
a8e71382
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
pin.go
pin.go
+18
-18
No files found.
pin.go
View file @
12448909
...
...
@@ -43,14 +43,14 @@ const (
linkAll
=
"all"
)
//
Pin
Mode allows to specify different types of pin (recursive, direct etc.).
// Mode allows to specify different types of pin (recursive, direct etc.).
// See the Pin Modes constants for a full list.
type
Pin
Mode
int
type
Mode
int
// Pin Modes
const
(
// Recursive pins pin the target cids along with any reachable children.
Recursive
Pin
Mode
=
iota
Recursive
Mode
=
iota
// Direct pins pin just the target cid.
Direct
...
...
@@ -68,9 +68,9 @@ const (
Any
)
//
Pin
ModeToString returns a human-readable name for the
Pin
Mode.
func
Pin
ModeToString
(
mode
Pin
Mode
)
(
string
,
bool
)
{
m
:=
map
[
Pin
Mode
]
string
{
// ModeToString returns a human-readable name for the Mode.
func
ModeToString
(
mode
Mode
)
(
string
,
bool
)
{
m
:=
map
[
Mode
]
string
{
Recursive
:
linkRecursive
,
Direct
:
linkDirect
,
Indirect
:
linkIndirect
,
...
...
@@ -82,10 +82,10 @@ func PinModeToString(mode PinMode) (string, bool) {
return
s
,
ok
}
// StringTo
Pin
Mode parses the result of
Pin
ModeToString() back to a
Pin
Mode.
// StringToMode parses the result of ModeToString() back to a Mode.
// It returns a boolean which is set to false if the mode is unknown.
func
StringTo
Pin
Mode
(
s
string
)
(
Pin
Mode
,
bool
)
{
m
:=
map
[
string
]
Pin
Mode
{
func
StringToMode
(
s
string
)
(
Mode
,
bool
)
{
m
:=
map
[
string
]
Mode
{
linkRecursive
:
Recursive
,
linkDirect
:
Direct
,
linkIndirect
:
Indirect
,
...
...
@@ -109,7 +109,7 @@ type Pinner interface {
// 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
,
Pin
Mode
)
(
string
,
bool
,
error
)
IsPinnedWithType
(
*
cid
.
Cid
,
Mode
)
(
string
,
bool
,
error
)
// Pin the given node, optionally recursively.
Pin
(
ctx
context
.
Context
,
node
ipld
.
Node
,
recursive
bool
)
error
...
...
@@ -130,12 +130,12 @@ type Pinner interface {
// PinWithMode is for manually editing the pin structure. Use with
// care! If used improperly, garbage collection may not be
// successful.
PinWithMode
(
*
cid
.
Cid
,
Pin
Mode
)
PinWithMode
(
*
cid
.
Cid
,
Mode
)
// RemovePinWithMode is for manually editing the pin structure.
// Use with care! If used improperly, garbage collection may not
// be successful.
RemovePinWithMode
(
*
cid
.
Cid
,
Pin
Mode
)
RemovePinWithMode
(
*
cid
.
Cid
,
Mode
)
// Flush writes the pin state to the backing datastore
Flush
()
error
...
...
@@ -157,7 +157,7 @@ type Pinner interface {
// by some ascendant).
type
Pinned
struct
{
Key
*
cid
.
Cid
Mode
Pin
Mode
Mode
Mode
Via
*
cid
.
Cid
}
...
...
@@ -174,7 +174,7 @@ func (p Pinned) String() string {
case
Indirect
:
return
fmt
.
Sprintf
(
"pinned via %s"
,
p
.
Via
)
default
:
modeStr
,
_
:=
Pin
ModeToString
(
p
.
Mode
)
modeStr
,
_
:=
ModeToString
(
p
.
Mode
)
return
fmt
.
Sprintf
(
"pinned: %s"
,
modeStr
)
}
}
...
...
@@ -293,7 +293,7 @@ func (p *pinner) IsPinned(c *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.
func
(
p
*
pinner
)
IsPinnedWithType
(
c
*
cid
.
Cid
,
mode
Pin
Mode
)
(
string
,
bool
,
error
)
{
func
(
p
*
pinner
)
IsPinnedWithType
(
c
*
cid
.
Cid
,
mode
Mode
)
(
string
,
bool
,
error
)
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
return
p
.
isPinnedWithType
(
c
,
mode
)
...
...
@@ -301,7 +301,7 @@ func (p *pinner) IsPinnedWithType(c *cid.Cid, mode PinMode) (string, bool, error
// isPinnedWithType is the implementation of IsPinnedWithType that does not lock.
// intended for use by other pinned methods that already take locks
func
(
p
*
pinner
)
isPinnedWithType
(
c
*
cid
.
Cid
,
mode
Pin
Mode
)
(
string
,
bool
,
error
)
{
func
(
p
*
pinner
)
isPinnedWithType
(
c
*
cid
.
Cid
,
mode
Mode
)
(
string
,
bool
,
error
)
{
switch
mode
{
case
Any
,
Direct
,
Indirect
,
Recursive
,
Internal
:
default
:
...
...
@@ -414,7 +414,7 @@ func (p *pinner) CheckIfPinned(cids ...*cid.Cid) ([]Pinned, error) {
// 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
Pin
Mode
)
{
func
(
p
*
pinner
)
RemovePinWithMode
(
c
*
cid
.
Cid
,
mode
Mode
)
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
switch
mode
{
...
...
@@ -594,7 +594,7 @@ func (p *pinner) InternalPins() []*cid.Cid {
// PinWithMode allows the user to have fine grained control over pin
// counts
func
(
p
*
pinner
)
PinWithMode
(
c
*
cid
.
Cid
,
mode
Pin
Mode
)
{
func
(
p
*
pinner
)
PinWithMode
(
c
*
cid
.
Cid
,
mode
Mode
)
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
switch
mode
{
...
...
This diff is collapsed.
Click to expand it.
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