diff --git a/pkg/container/reader.go b/pkg/container/reader.go index 61402e4..db1e145 100644 --- a/pkg/container/reader.go +++ b/pkg/container/reader.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "fmt" "io" + "iter" "github.com/ipfs/go-cid" "github.com/ipld/go-ipld-prime" @@ -42,6 +43,19 @@ func (ctn Reader) GetDelegation(cid cid.Cid) (*delegation.Token, error) { return nil, fmt.Errorf("not a delegation token") } +// GetAllDelegations returns all the delegation.Token in the container. +func (ctn Reader) GetAllDelegations() iter.Seq2[cid.Cid, *delegation.Token] { + return func(yield func(cid.Cid, *delegation.Token) bool) { + for c, t := range ctn { + if t, ok := t.(*delegation.Token); ok { + if !yield(c, t) { + return + } + } + } + } +} + // GetInvocation returns the first found invocation.Token. // If none are found, ErrNotFound is returned. func (ctn Reader) GetInvocation() (*invocation.Token, error) {