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
e3ac58db
Commit
e3ac58db
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite add command to use dagwriter, moved a pinner into the dagwriter for inline pinning
parent
9ddd1b6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
pin.go
pin.go
+26
-0
No files found.
pin.go
View file @
e3ac58db
...
...
@@ -20,6 +20,14 @@ var recursePinDatastoreKey = ds.NewKey("/local/pins/recursive/keys")
var
directPinDatastoreKey
=
ds
.
NewKey
(
"/local/pins/direct/keys"
)
var
indirectPinDatastoreKey
=
ds
.
NewKey
(
"/local/pins/indirect/keys"
)
type
PinMode
int
const
(
Recursive
PinMode
=
iota
Direct
Indirect
)
type
Pinner
interface
{
IsPinned
(
util
.
Key
)
bool
Pin
(
*
mdag
.
Node
,
bool
)
error
...
...
@@ -27,6 +35,13 @@ type Pinner interface {
Flush
()
error
}
// ManualPinner is for manually editing the pin structure
// Use with care
type
ManualPinner
interface
{
PinWithMode
(
util
.
Key
,
PinMode
)
Pinner
}
type
pinner
struct
{
lock
sync
.
RWMutex
recursePin
set
.
BlockSet
...
...
@@ -228,3 +243,14 @@ func loadSet(d ds.Datastore, k ds.Key, val interface{}) error {
}
return
json
.
Unmarshal
(
bf
,
val
)
}
func
(
p
*
pinner
)
PinWithMode
(
k
util
.
Key
,
mode
PinMode
)
{
switch
mode
{
case
Recursive
:
p
.
recursePin
.
AddBlock
(
k
)
case
Direct
:
p
.
directPin
.
AddBlock
(
k
)
case
Indirect
:
p
.
indirPin
.
Increment
(
k
)
}
}
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