Unverified Commit 495dd3cb authored by Adin Schmahmann's avatar Adin Schmahmann Committed by GitHub

Merge pull request #1 from ipfs/feat/async-ds

Support Async Datastores
parents 05f55f1b 5901eab2
Pipeline #172 failed with stages
in 0 seconds
......@@ -192,6 +192,11 @@ type pinner struct {
dstore ds.Datastore
}
type syncDAGService interface {
ipld.DAGService
Sync() error
}
// NewPinner creates a new pinner using the given datastore as a backend
func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner {
......@@ -576,9 +581,25 @@ func (p *pinner) Flush(ctx context.Context) error {
k := root.Cid()
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 {
return fmt.Errorf("cannot store pin state: %v", err)
}
if err := p.dstore.Sync(pinDatastoreKey); err != nil {
return fmt.Errorf("cannot sync pin state: %v", err)
}
p.internalPin = internalset
return nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment