Skip to content

Commit fb5018e

Browse files
committed
fix: container interface
1 parent 067cc38 commit fb5018e

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

ucan/container/container.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const (
2626
Base64urlGzip = byte(0x46) // base64 url (no padding), gzip
2727
)
2828

29-
var ErrNotFound = errors.New("not found")
30-
3129
// FormatCodec converts a container codec code into a human readable string.
3230
func FormatCodec(codec byte) string {
3331
switch codec {
@@ -58,13 +56,13 @@ func (c *Container) Delegations() []ucan.Delegation {
5856
return c.dlgs
5957
}
6058

61-
func (c *Container) Delegation(root cid.Cid) (ucan.Delegation, error) {
59+
func (c *Container) Delegation(root cid.Cid) (ucan.Delegation, bool) {
6260
for _, dlg := range c.dlgs {
6361
if dlg.Link() == root {
64-
return dlg, nil
62+
return dlg, true
6563
}
6664
}
67-
return nil, ErrNotFound
65+
return nil, false
6866
}
6967

7068
func (c *Container) Invocations() []ucan.Invocation {
@@ -75,13 +73,13 @@ func (c *Container) Receipts() []ucan.Receipt {
7573
return c.rcpts
7674
}
7775

78-
func (c *Container) Receipt(task cid.Cid) (ucan.Receipt, error) {
76+
func (c *Container) Receipt(task cid.Cid) (ucan.Receipt, bool) {
7977
for _, rcpt := range c.rcpts {
8078
if rcpt.Ran() == task {
81-
return rcpt, nil
79+
return rcpt, true
8280
}
8381
}
84-
return nil, ErrNotFound
82+
return nil, false
8583
}
8684

8785
func (c *Container) MarshalCBOR(w io.Writer) error {

ucan/ucan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ type Container interface {
228228
// Delegations the container contains.
229229
Delegations() []Delegation
230230
// Delegation retrieves a delegation from the container by it's CID.
231-
Delegation(Link) (Delegation, error)
231+
Delegation(Link) (Delegation, bool)
232232
// Receipts the container contains.
233233
Receipts() []Receipt
234234
// Receipt retrieves a receipt from the container by the CID of a [Task] that
235235
// was executed.
236-
Receipt(Link) (Receipt, error)
236+
Receipt(Link) (Receipt, bool)
237237
}
238238

239239
// IsExpired checks if a UCAN is expired.

0 commit comments

Comments
 (0)