@cryptotaxi247 / kubo / commits / 04c548b1d

coreapi: dag: Batching interface

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@f4b74679d1eb5597e430a52f4cca826d511898c3 This commit was moved from ipfs/boxo@83081a0c1b91bb9554d56ea074ef28ca02b38ed9

Łukasz Magiera committed Aug 3, 2018 at 18:06 UTC 04c548b1d2e75aa0f31755a90b1d059ff9210dc6
1 file changed +18 -3
core/coreiface/dag.go
+18 -3
@@ -4,21 +4,36 @@ import (
4 "context"
5 "io"
6
7 - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
7 + "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
8
9 ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
10 )
11
12 -// DagAPI specifies the interface to IPLD
13 -type DagAPI interface {
12 +// DagOps groups operations that can be batched together
13 +type DagOps interface {
14 // Put inserts data using specified format and input encoding.
15 // Unless used with WithCodec or WithHash, the defaults "dag-cbor" and
16 // "sha256" are used.
17 Put(ctx context.Context, src io.Reader, opts ...options.DagPutOption) (ResolvedPath, error)
18 +}
19 +
20 +// DagBatch is the batching version of DagAPI. All implementations of DagBatch
21 +// should be threadsafe
22 +type DagBatch interface {
23 + DagOps
24 +
25 + Commit(ctx context.Context) error
26 +}
27 +
28 +// DagAPI specifies the interface to IPLD
29 +type DagAPI interface {
30 + DagOps
31
32 // Get attempts to resolve and get the node specified by the path
33 Get(ctx context.Context, path Path) (ipld.Node, error)
34
35 // Tree returns list of paths within a node specified by the path.
36 Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error)
37 +
38 + Batch(ctx context.Context) DagBatch
39 }