Skip to content

Commit

Permalink
Merge pull request #6085 from ipfs/fix/thread-safe-mem-datastore
Browse files Browse the repository at this point in the history
make in-memory datastore thread-safe
  • Loading branch information
Stebalien authored Mar 16, 2019
2 parents 65d093c + 3c383bc commit 221d1b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion repo/fsrepo/datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/mount"
dssync "github.com/ipfs/go-datastore/sync"
"github.com/ipfs/go-ds-measure"
)

Expand Down Expand Up @@ -174,7 +175,7 @@ func (c *memDatastoreConfig) DiskSpec() DiskSpec {
}

func (c *memDatastoreConfig) Create(string) (repo.Datastore, error) {
return ds.NewMapDatastore(), nil
return dssync.MutexWrap(ds.NewMapDatastore()), nil
}

type logDatastoreConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ type Repo interface {
// Datastore is the interface required from a datastore to be
// acceptable to FSRepo.
type Datastore interface {
ds.Batching // should be threadsafe, just be careful
ds.Batching // must be thread-safe
}

0 comments on commit 221d1b1

Please sign in to comment.