Commit f4b74679 authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: dag: Batching interface

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent af43bf0a
...@@ -4,21 +4,36 @@ import ( ...@@ -4,21 +4,36 @@ import (
"context" "context"
"io" "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" ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
) )
// DagAPI specifies the interface to IPLD // DagOps groups operations that can be batched together
type DagAPI interface { type DagOps interface {
// Put inserts data using specified format and input encoding. // Put inserts data using specified format and input encoding.
// Unless used with WithCodec or WithHash, the defaults "dag-cbor" and // Unless used with WithCodec or WithHash, the defaults "dag-cbor" and
// "sha256" are used. // "sha256" are used.
Put(ctx context.Context, src io.Reader, opts ...options.DagPutOption) (ResolvedPath, error) 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 attempts to resolve and get the node specified by the path
Get(ctx context.Context, path Path) (ipld.Node, error) Get(ctx context.Context, path Path) (ipld.Node, error)
// Tree returns list of paths within a node specified by the path. // Tree returns list of paths within a node specified by the path.
Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error) Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error)
Batch(ctx context.Context) DagBatch
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment