Skip to content

Commit

Permalink
Merge pull request #566 from jbenet/races
Browse files Browse the repository at this point in the history
race fixes
  • Loading branch information
Brian Tiger Chow committed Jan 15, 2015
2 parents 4af5d85 + 16690d4 commit 47701aa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions importer/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ type dagservAndPinner struct {
}

func getDagservAndPinner(t *testing.T) dagservAndPinner {
db := ds.NewMapDatastore()
bs := bstore.NewBlockstore(dssync.MutexWrap(db))
db := dssync.MutexWrap(ds.NewMapDatastore())
bs := bstore.NewBlockstore(db)
blockserv, err := bserv.New(bs, offline.Exchange(bs))
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions merkledag/merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type dagservAndPinner struct {
}

func getDagservAndPinner(t *testing.T) dagservAndPinner {
db := ds.NewMapDatastore()
bs := bstore.NewBlockstore(dssync.MutexWrap(db))
db := dssync.MutexWrap(ds.NewMapDatastore())
bs := bstore.NewBlockstore(db)
blockserv, err := bserv.New(bs, offline.Exchange(bs))
if err != nil {
t.Fatal(err)
Expand Down
6 changes: 3 additions & 3 deletions pin/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ type pinner struct {
directPin set.BlockSet
indirPin *indirectPin
dserv mdag.DAGService
dstore ds.Datastore
dstore ds.ThreadSafeDatastore
}

// NewPinner creates a new pinner using the given datastore as a backend
func NewPinner(dstore ds.Datastore, serv mdag.DAGService) Pinner {
func NewPinner(dstore ds.ThreadSafeDatastore, serv mdag.DAGService) Pinner {

// Load set from given datastore...
rcds := nsds.Wrap(dstore, recursePinDatastoreKey)
Expand Down Expand Up @@ -176,7 +176,7 @@ func (p *pinner) IsPinned(key util.Key) bool {
}

// LoadPinner loads a pinner and its keysets from the given datastore
func LoadPinner(d ds.Datastore, dserv mdag.DAGService) (Pinner, error) {
func LoadPinner(d ds.ThreadSafeDatastore, dserv mdag.DAGService) (Pinner, error) {
p := new(pinner)

{ // load recursive set
Expand Down
4 changes: 2 additions & 2 deletions pin/pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func randNode() (*mdag.Node, util.Key) {
}

func TestPinnerBasic(t *testing.T) {
dstore := ds.NewMapDatastore()
bstore := blockstore.NewBlockstore(dssync.MutexWrap(dstore))
dstore := dssync.MutexWrap(ds.NewMapDatastore())
bstore := blockstore.NewBlockstore(dstore)
bserv, err := bs.New(bstore, offline.Exchange(bstore))
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 47701aa

Please sign in to comment.