Skip to content

Commit

Permalink
coreapi: dag: Batching interface
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@f4b7467
  • Loading branch information
magik6k committed Aug 3, 2018
1 parent c1cdbfd commit 83081a0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions coreiface/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,36 @@ import (
"context"
"io"

options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"

ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
)

// DagAPI specifies the interface to IPLD
type DagAPI interface {
// DagOps groups operations that can be batched together
type DagOps interface {
// Put inserts data using specified format and input encoding.
// Unless used with WithCodec or WithHash, the defaults "dag-cbor" and
// "sha256" are used.
Put(ctx context.Context, src io.Reader, opts ...options.DagPutOption) (ResolvedPath, error)
}

// DagBatch is the batching version of DagAPI. All implementations of DagBatch
// should be threadsafe
type DagBatch interface {
DagOps

Commit(ctx context.Context) error
}

// DagAPI specifies the interface to IPLD
type DagAPI interface {
DagOps

// Get attempts to resolve and get the node specified by the path
Get(ctx context.Context, path Path) (ipld.Node, error)

// Tree returns list of paths within a node specified by the path.
Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error)

Batch(ctx context.Context) DagBatch
}

0 comments on commit 83081a0

Please sign in to comment.