errservice.go 1.05 KB
Newer Older
Jeromy's avatar
Jeromy committed
1 2 3 4 5
package merkledag

import (
	"context"

6 7
	cid "gitlab.dms3.io/dms3/go-cid"
	ld "gitlab.dms3.io/dms3/go-ld-format"
Jeromy's avatar
Jeromy committed
8 9
)

10
// ErrorService implements ld.DAGService, returning 'Err' for every call.
Jeromy's avatar
Jeromy committed
11 12 13 14
type ErrorService struct {
	Err error
}

15
var _ ld.DAGService = (*ErrorService)(nil)
Jeromy's avatar
Jeromy committed
16

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

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

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

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

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

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