func (g *Graph) GetDidAnchors(hl, suffix string) ([]Anchor, error) {
	var refs []Anchor
	logger.Debugf("getting did anchors for hl[%s], suffix[%s]", hl, suffix)
	cur := hl
	ok := true
	for ok {
		anchorEvent, err := g.Read(cur)
		if err != nil {
			return nil, fmt.Errorf("failed to read anchor event[%s] for did[%s]: %w", cur, suffix, err)
		}
		refs = append(refs, Anchor{
			CID:  cur,
			Info: anchorEvent,
		})
		payload, err := anchorevent.GetPayloadFromAnchorEvent(anchorEvent)
		if err != nil {
			return nil, err
		}
		previousAnchors := payload.PreviousAnchors
		cur, ok = contains(suffix, previousAnchors)
		if ok && cur == "" {  
			break
		}
	}
	return reverseOrder(refs), nil
}
GetDidAnchors returns all anchors that are referencing did suffix starting from hl.
package graph
import (
	"encoding/json"
	"fmt"
	"net/url"
	"github.com/piprate/json-gold/ld"
	"github.com/trustbloc/edge-core/pkg/log"
	"github.com/trustbloc/sidetree-core-go/pkg/canonicalizer"
	"github.com/trustbloc/orb/pkg/activitypub/vocab"
	"github.com/trustbloc/orb/pkg/anchor/anchorevent"
	"github.com/trustbloc/orb/pkg/anchor/subject"
	"github.com/trustbloc/orb/pkg/errors"
)
var logger = log.New("anchor-graph")
type Graph struct {
	*Providers
}
type Providers struct {
	CasWriter   casWriter
	CasResolver casResolver
	DocLoader   ld.DocumentLoader
}
func New(providers *Providers) *Graph {
	return &Graph{
		Providers: providers,
	}
}
type casResolver interface {
	Resolve(webCASURL *url.URL, hl string, data []byte) ([]byte, string, error)
}
type casWriter interface {
	Write(content []byte) (string, error)
}
func (g *Graph) Add(anchorEvent *vocab.AnchorEventType) (string, error) {  
	canonicalBytes, err := canonicalizer.MarshalCanonical(anchorEvent)
	if err != nil {
		return "", fmt.Errorf("failed to marshal anchor event: %w", err)
	}
	hl, err := g.CasWriter.Write(canonicalBytes)
	if err != nil {
		return "", errors.NewTransient(fmt.Errorf("failed to add anchor to graph: %w", err))
	}
	logger.Debugf("added anchor event[%s]: %s", hl, string(canonicalBytes))
	return hl, nil
}
func (g *Graph) Read(hl string) (*vocab.AnchorEventType, error) {
	anchorEventBytes, _, err := g.CasResolver.Resolve(nil, hl, nil)
	if err != nil {
		return nil, err
	}
	logger.Debugf("read anchor event [%s]: %s", hl, string(anchorEventBytes))
	anchorEvent := &vocab.AnchorEventType{}
	err = json.Unmarshal(anchorEventBytes, anchorEvent)
	if err != nil {
		return nil, fmt.Errorf("unmarshal anchor event: %w", err)
	}
	return anchorEvent, nil
}
type Anchor struct {
	Info *vocab.AnchorEventType
	CID  string
}