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
5901eab2
Commit
5901eab2
authored
5 years ago
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for asynchronous datastores
parent
f462ad6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
go.sum
go.sum
+1
-2
pin.go
pin.go
+18
-0
No files found.
go.sum
View file @
5901eab2
...
@@ -76,8 +76,7 @@ github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAK
...
@@ -76,8 +76,7 @@ github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAK
github.com/ipfs/go-datastore
v0.0.5/go.mod h1:
d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore
v0.0.5/go.mod h1:
d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore
v0.1.0 h1:
TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI=
github.com/ipfs/go-datastore
v0.1.0 h1:
TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI=
github.com/ipfs/go-datastore
v0.1.0/go.mod h1:
d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore
v0.1.0/go.mod h1:
d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore
v0.1.1 h1:
F4k0TkTAZGLFzBOrVKDAvch6JZtuN4NHkfdcEZL50aI=
github.com/ipfs/go-datastore
v0.3.0 h1:
9au0tYi/+n7xeUnGHG6davnS8x9hWbOzP/388Vx3CMs=
github.com/ipfs/go-datastore
v0.1.1/go.mod h1:
w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-datastore
v0.3.0/go.mod h1:
w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-datastore
v0.3.0/go.mod h1:
w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-detect-race
v0.0.1 h1:
qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race
v0.0.1 h1:
qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race
v0.0.1/go.mod h1:
8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-detect-race
v0.0.1/go.mod h1:
8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
...
...
This diff is collapsed.
Click to expand it.
pin.go
View file @
5901eab2
...
@@ -192,6 +192,11 @@ type pinner struct {
...
@@ -192,6 +192,11 @@ type pinner struct {
dstore
ds
.
Datastore
dstore
ds
.
Datastore
}
}
type
syncDAGService
interface
{
ipld
.
DAGService
Sync
()
error
}
// NewPinner creates a new pinner using the given datastore as a backend
// NewPinner creates a new pinner using the given datastore as a backend
func
NewPinner
(
dstore
ds
.
Datastore
,
serv
,
internal
ipld
.
DAGService
)
Pinner
{
func
NewPinner
(
dstore
ds
.
Datastore
,
serv
,
internal
ipld
.
DAGService
)
Pinner
{
...
@@ -576,6 +581,19 @@ func (p *pinner) Flush(ctx context.Context) error {
...
@@ -576,6 +581,19 @@ func (p *pinner) Flush(ctx context.Context) error {
k
:=
root
.
Cid
()
k
:=
root
.
Cid
()
internalset
.
Add
(
k
)
internalset
.
Add
(
k
)
if
syncDServ
,
ok
:=
p
.
dserv
.
(
syncDAGService
);
ok
{
if
err
:=
syncDServ
.
Sync
();
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot sync pinned data: %v"
,
err
)
}
}
if
syncInternal
,
ok
:=
p
.
internal
.
(
syncDAGService
);
ok
{
if
err
:=
syncInternal
.
Sync
();
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot sync pinning data: %v"
,
err
)
}
}
if
err
:=
p
.
dstore
.
Put
(
pinDatastoreKey
,
k
.
Bytes
());
err
!=
nil
{
if
err
:=
p
.
dstore
.
Put
(
pinDatastoreKey
,
k
.
Bytes
());
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot store pin state: %v"
,
err
)
return
fmt
.
Errorf
(
"cannot store pin state: %v"
,
err
)
}
}
...
...
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