errservice.go 1.13 KB
Newer Older
Jeromy's avatar
Jeromy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
package merkledag

import (
	"context"

	cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
	ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)

// ErrorService implements ipld.DAGService, returning 'Err' for every call.
type ErrorService struct {
	Err error
}

var _ ipld.DAGService = (*ErrorService)(nil)

17
// Add returns an error.
Jeromy's avatar
Jeromy committed
18 19 20 21
func (cs *ErrorService) Add(ctx context.Context, nd ipld.Node) error {
	return cs.Err
}

22
// AddMany returns an error.
Jeromy's avatar
Jeromy committed
23 24 25 26
func (cs *ErrorService) AddMany(ctx context.Context, nds []ipld.Node) error {
	return cs.Err
}

27
// Get returns an error.
Jeromy's avatar
Jeromy committed
28 29 30 31
func (cs *ErrorService) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
	return nil, cs.Err
}

32
// GetMany many returns an error.
Jeromy's avatar
Jeromy committed
33 34 35 36 37 38
func (cs *ErrorService) GetMany(ctx context.Context, cids []*cid.Cid) <-chan *ipld.NodeOption {
	ch := make(chan *ipld.NodeOption)
	close(ch)
	return ch
}

39
// Remove returns an error.
Jeromy's avatar
Jeromy committed
40 41 42 43
func (cs *ErrorService) Remove(ctx context.Context, c *cid.Cid) error {
	return cs.Err
}

44
// RemoveMany returns an error.
Jeromy's avatar
Jeromy committed
45 46 47
func (cs *ErrorService) RemoveMany(ctx context.Context, cids []*cid.Cid) error {
	return cs.Err
}