Skip to content
Open
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
2 changes: 1 addition & 1 deletion pkg/client/accessdelegate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestAccessDelegate(t *testing.T) {
inv invocation.Invocation,
context server.InvocationContext,
) (result.Result[access.DelegateOk, failure.IPLDBuilderFailure], fx.Effects, error) {
return result.Error[access.DelegateOk, failure.IPLDBuilderFailure](
return result.Error[access.DelegateOk](
failure.FromError(fmt.Errorf("test error")),
), nil, nil
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
captypes "github.com/storacha/go-libstoracha/capabilities/types"
ucancap "github.com/storacha/go-libstoracha/capabilities/ucan"
uclient "github.com/storacha/go-ucanto/client"
rclient "github.com/storacha/go-ucanto/client/retrieval"
"github.com/storacha/go-ucanto/core/delegation"
"github.com/storacha/go-ucanto/core/invocation"
"github.com/storacha/go-ucanto/core/receipt"
Expand All @@ -34,6 +35,7 @@ import (
var (
log = logging.Logger("github.com/storacha/guppy/pkg/client")
tracer = otel.Tracer("github.com/storacha/guppy/pkg/client")
meter = otel.Meter("github.com/storacha/guppy/pkg/client")
)

type Client struct {
Expand All @@ -42,6 +44,7 @@ type Client struct {
data agentdata.AgentData
saveFn func(agentdata.AgentData) error
additionalProofs []delegation.Delegation
retrievalOpts []rclient.Option
}

// NewClient creates a new client.
Expand Down
17 changes: 13 additions & 4 deletions pkg/client/dagservice/dagservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,39 @@ package dagservice

import (
"context"
"io"

"github.com/ipfs/boxo/blockservice"
"github.com/ipfs/boxo/blockstore"
"github.com/ipfs/boxo/ipld/merkledag"
ds "github.com/ipfs/go-datastore"
dssync "github.com/ipfs/go-datastore/sync"
ipldfmt "github.com/ipfs/go-ipld-format"
rclient "github.com/storacha/go-ucanto/client/retrieval"
logging "github.com/ipfs/go-log/v2"
"github.com/storacha/go-ucanto/did"
"github.com/storacha/guppy/pkg/client"
"github.com/storacha/guppy/pkg/client/locator"
"go.opentelemetry.io/otel"
)

var (
log = logging.Logger("client/dagservice")
tracer = otel.Tracer("client/dagservice")
)

// Retriever can fetch content from a given [locator.Location]. `Retrieve` does
// no data validation.
type Retriever interface {
Retrieve(ctx context.Context, space did.DID, location locator.Location, retrievalOpts ...rclient.Option) ([]byte, error)
Retrieve(ctx context.Context, location locator.Location) (io.ReadCloser, error)
}

var _ Retriever = (*client.Client)(nil)

func NewDAGService(locator locator.Locator, retriever Retriever, space did.DID) ipldfmt.DAGService {
func NewDAGService(locator locator.Locator, retriever Retriever, space did.DID, opts ...ExchangeOption) ipldfmt.DAGService {
return merkledag.NewReadOnlyDagService(
merkledag.NewDAGService(blockservice.New(
blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore())),
NewExchange(locator, retriever, space),
NewExchange(locator, retriever, space, opts...),
)),
)
}
Loading
Loading