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

import (
4 5 6
	bsrv "github.com/ipfs/go-ipfs/blockservice"
	"github.com/ipfs/go-ipfs/exchange/offline"
	dag "github.com/ipfs/go-ipfs/merkledag"
7

Steven Allen's avatar
Steven Allen committed
8 9
	ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
	dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
10
	blockstore "gx/ipfs/QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b/go-ipfs-blockstore"
11
	ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/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
}