utils.go 663 Bytes
Newer Older
1
package mdutils
2 3

import (
Jeromy's avatar
Jeromy committed
4
	dag "github.com/ipfs/go-merkledag"
5

Jeromy's avatar
Jeromy committed
6 7 8 9 10 11
	bsrv "github.com/ipfs/go-blockservice"
	ds "github.com/ipfs/go-datastore"
	dssync "github.com/ipfs/go-datastore/sync"
	blockstore "github.com/ipfs/go-ipfs-blockstore"
	offline "github.com/ipfs/go-ipfs-exchange-offline"
	ipld "github.com/ipfs/go-ipld-format"
12 13
)

Steven Allen's avatar
Steven Allen committed
14
// Mock returns a new thread-safe, mock DAGService.
15
func Mock() ipld.DAGService {
16 17 18
	return dag.NewDAGService(Bserv())
}

Steven Allen's avatar
Steven Allen committed
19
// Bserv returns a new, thread-safe, mock BlockService.
20
func Bserv() bsrv.BlockService {
21
	bstore := blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore()))
22
	return bsrv.New(bstore, offline.Exchange(bstore))
23
}