Unverified 提交 221d1b13 作者: Steven Allen 提交者: GitHub

Merge pull request #6085 from ipfs/fix/thread-safe-mem-datastore

make in-memory datastore thread-safe
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/mount" "github.com/ipfs/go-datastore/mount"
dssync "github.com/ipfs/go-datastore/sync"
"github.com/ipfs/go-ds-measure" "github.com/ipfs/go-ds-measure"
) )
...@@ -174,7 +175,7 @@ func (c *memDatastoreConfig) DiskSpec() DiskSpec { ...@@ -174,7 +175,7 @@ func (c *memDatastoreConfig) DiskSpec() DiskSpec {
} }
func (c *memDatastoreConfig) Create(string) (repo.Datastore, error) { func (c *memDatastoreConfig) Create(string) (repo.Datastore, error) {
return ds.NewMapDatastore(), nil return dssync.MutexWrap(ds.NewMapDatastore()), nil
} }
type logDatastoreConfig struct { type logDatastoreConfig struct {
......
...@@ -59,5 +59,5 @@ type Repo interface { ...@@ -59,5 +59,5 @@ type Repo interface {
// Datastore is the interface required from a datastore to be // Datastore is the interface required from a datastore to be
// acceptable to FSRepo. // acceptable to FSRepo.
type Datastore interface { type Datastore interface {
ds.Batching // should be threadsafe, just be careful ds.Batching // must be thread-safe
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论