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

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

Steven Allen's avatar
Steven Allen committed
7
	offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
Steven Allen's avatar
Steven Allen committed
8
	ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
Steven Allen's avatar
Steven Allen committed
9
	blockstore "gx/ipfs/QmadMhXJLHMFjpRmh85XjpmVDkEtQpNYEZNRpWRvYVLrvb/go-ipfs-blockstore"
Steven Allen's avatar
Steven Allen committed
10 11
	ds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore"
	dssync "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync"
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
}