@cryptotaxi247 / kubo / commits / c56118567

coreapi: draft block API

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

Łukasz Magiera committed Jan 5, 2018 at 01:50 UTC c56118567677371082f7ff08a2556b101a887b06
2 files changed +32
core/coreiface/interface.go
+18
@@ -53,6 +53,11 @@ type Key interface {
53 Path() Path
54 }
55
56 +type BlockStat interface {
57 + Size() int
58 + Path() Path
59 +}
60 +
61 // CoreAPI defines an unified interface to IPFS for Go programs.
62 type CoreAPI interface {
63 // Unixfs returns an implementation of Unixfs API.
@@ -87,6 +92,19 @@ type UnixfsAPI interface {
92 Ls(context.Context, Path) ([]*Link, error)
93 }
94
95 +type BlockAPI interface {
96 + Put(context.Context, io.Reader) (Path, error)
97 + WithCodec(codec uint64) options.BlockPutOption
98 + WithHash(mhType uint64, mhLen int) options.BlockPutOption
99 +
100 + Get(context.Context) (io.Reader, error)
101 +
102 + Rm(context.Context) error
103 + WithForce(force bool) options.BlockRmOption
104 +
105 + Stat(context.Context) (BlockStat, error)
106 +}
107 +
108 // DagAPI specifies the interface to IPLD
109 type DagAPI interface {
110 // Put inserts data using specified format and input encoding.
core/coreiface/options/block.go new
+14
@@ -0,0 +1,14 @@
1 +package options
2 +
3 +type BlockPutSettings struct {
4 + Codec uint64
5 + MhType uint64
6 + MhLength int
7 +}
8 +
9 +type BlockRmSettings struct {
10 + Force bool
11 +}
12 +
13 +type BlockPutOption func(*BlockPutSettings) error
14 +type BlockRmOption func(*BlockRmSettings) error