@cryptotaxi247 / kubo / commits / 3c383bcc8

make in-memory datastore thread-safe

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Mar 15, 2019 at 15:43 UTC 3c383bcc8b1289fa52506300356aa40b1e3f3105
2 files changed +3 -2
repo/fsrepo/datastores.go
+2 -1
@@ -10,6 +10,7 @@ import (
10
11 ds "github.com/ipfs/go-datastore"
12 "github.com/ipfs/go-datastore/mount"
13 + dssync "github.com/ipfs/go-datastore/sync"
14 "github.com/ipfs/go-ds-measure"
15 )
16
@@ -174,7 +175,7 @@ func (c *memDatastoreConfig) DiskSpec() DiskSpec {
175 }
176
177 func (c *memDatastoreConfig) Create(string) (repo.Datastore, error) {
177 - return ds.NewMapDatastore(), nil
178 + return dssync.MutexWrap(ds.NewMapDatastore()), nil
179 }
180
181 type logDatastoreConfig struct {
repo/repo.go
+1 -1
@@ -59,5 +59,5 @@ type Repo interface {
59 // Datastore is the interface required from a datastore to be
60 // acceptable to FSRepo.
61 type Datastore interface {
62 - ds.Batching // should be threadsafe, just be careful
62 + ds.Batching // must be thread-safe
63 }