Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blobindex/datamodel/cbor_gen.maps.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blobindex/datamodel/cbor_gen.tuples.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blobindex/datamodel/json_gen.maps.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blobindex/datamodel/json_gen.tuples.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions capabilities/blob/datamodel/accept.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package datamodel

import (
"github.com/fil-forge/ucantone/ucan"
"github.com/fil-forge/ucantone/ucan/promise"
cid "github.com/ipfs/go-cid"
)

type AcceptArgumentsModel struct {
Expand All @@ -11,5 +11,5 @@ type AcceptArgumentsModel struct {
}

type AcceptOKModel struct {
Site ucan.Link `cborgen:"site" dagjsongen:"site"`
Site cid.Cid `cborgen:"site" dagjsongen:"site"`
}
4 changes: 2 additions & 2 deletions capabilities/blob/datamodel/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package datamodel

import (
"github.com/fil-forge/libforge/capabilities"
"github.com/fil-forge/ucantone/ucan"
cid "github.com/ipfs/go-cid"
)

type AllocateArgumentsModel struct {
Blob BlobModel `cborgen:"blob" dagjsongen:"blob"`
Cause ucan.Link `cborgen:"cause" dagjsongen:"cause"`
Cause cid.Cid `cborgen:"cause" dagjsongen:"cause"`
}

type AllocateOKModel struct {
Expand Down
4 changes: 2 additions & 2 deletions capabilities/blob/datamodel/replicate.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package datamodel

import (
"github.com/fil-forge/ucantone/ucan"
"github.com/fil-forge/ucantone/ucan/promise"
cid "github.com/ipfs/go-cid"
)

type ReplicateArgumentsModel struct {
Expand All @@ -13,7 +13,7 @@ type ReplicateArgumentsModel struct {
Replicas uint64 `cborgen:"replicas" dagjsongen:"replicas"`
// Site is a link to a location commitment indicating where the Blob must be
// fetched from.
Site ucan.Link `cborgen:"site" dagjsongen:"site"`
Site cid.Cid `cborgen:"site" dagjsongen:"site"`
}

type ReplicateOKModel struct {
Expand Down
3 changes: 1 addition & 2 deletions capabilities/blob/replica/datamodel/allocate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datamodel

import (
"github.com/fil-forge/ucantone/ucan"
"github.com/fil-forge/ucantone/ucan/promise"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multihash"
Expand All @@ -17,7 +16,7 @@ type AllocateArgumentsModel struct {
Blob BlobModel `cborgen:"blob"`
// Site is a link to a location commitment indicating where the Blob must be
// fetched from.
Site ucan.Link `cborgen:"site"`
Site cid.Cid `cborgen:"site"`
// Cause is a link to the `/blob/replicate` task that caused this allocation.
Cause cid.Cid `cborgen:"cause"`
}
Expand Down
5 changes: 2 additions & 3 deletions capabilities/blob/replica/datamodel/transfer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datamodel

import (
"github.com/fil-forge/ucantone/ucan"
"github.com/fil-forge/ucantone/ucan/promise"
"github.com/ipfs/go-cid"
)
Expand All @@ -11,15 +10,15 @@ type TransferArgumentsModel struct {
Blob BlobModel `cborgen:"blob"`
// Site is a link to a location commitment indicating where the Blob must be
// fetched from.
Site ucan.Link `cborgen:"site"`
Site cid.Cid `cborgen:"site"`
// Cause links to the `/blob/replica/allocate` task that initiated this transfer.
Cause cid.Cid `cborgen:"cause"`
}

type TransferOKModel struct {
// Site links to the location commitment that indicate where the Blob has been
// transferred to.
Site ucan.Link `cborgen:"site"`
Site cid.Cid `cborgen:"site"`
// PDP links to the /pdp/accept task that will resolve when aggregation
// is complete and the piece is accepted.
PDP promise.AwaitOK `cborgen:"pdp"`
Expand Down
33 changes: 33 additions & 0 deletions didresolver/cacheresolver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package didresolver

import (
"context"
"time"

"github.com/fil-forge/ucantone/did"
"github.com/fil-forge/ucantone/ucan"
"github.com/patrickmn/go-cache"
)

type CachedResolver struct {
wrapped DIDVerifierResolverFunc
cache *cache.Cache
}

func NewCachedResolver(wrapped DIDVerifierResolverFunc, ttl time.Duration) (*CachedResolver, error) {
// items remain in the cache for `ttl`, expired items are purged every hour.
return &CachedResolver{wrapped: wrapped, cache: cache.New(ttl, time.Hour)}, nil
}

func (c *CachedResolver) Resolve(ctx context.Context, input did.DID) (ucan.Verifier, error) {
if out, found := c.cache.Get(input.String()); found {
return out.(ucan.Verifier), nil
Comment on lines +23 to +24
}
out, err := c.wrapped(ctx, input)
if err != nil {
return nil, err
}
c.cache.Set(input.String(), out, cache.DefaultExpiration)

return out, nil
}
Loading
Loading