提交 219eae76 作者: Łukasz Magiera

coreapi: draft block API

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 cb5bb7dd
...@@ -53,6 +53,11 @@ type Key interface { ...@@ -53,6 +53,11 @@ type Key interface {
Path() Path Path() Path
} }
type BlockStat interface {
Size() int
Path() Path
}
// CoreAPI defines an unified interface to IPFS for Go programs. // CoreAPI defines an unified interface to IPFS for Go programs.
type CoreAPI interface { type CoreAPI interface {
// Unixfs returns an implementation of Unixfs API. // Unixfs returns an implementation of Unixfs API.
...@@ -87,6 +92,19 @@ type UnixfsAPI interface { ...@@ -87,6 +92,19 @@ type UnixfsAPI interface {
Ls(context.Context, Path) ([]*Link, error) Ls(context.Context, Path) ([]*Link, error)
} }
type BlockAPI interface {
Put(context.Context, io.Reader) (Path, error)
WithCodec(codec uint64) options.BlockPutOption
WithHash(mhType uint64, mhLen int) options.BlockPutOption
Get(context.Context) (io.Reader, error)
Rm(context.Context) error
WithForce(force bool) options.BlockRmOption
Stat(context.Context) (BlockStat, error)
}
// DagAPI specifies the interface to IPLD // DagAPI specifies the interface to IPLD
type DagAPI interface { type DagAPI interface {
// Put inserts data using specified format and input encoding. // Put inserts data using specified format and input encoding.
......
package options
type BlockPutSettings struct {
Codec uint64
MhType uint64
MhLength int
}
type BlockRmSettings struct {
Force bool
}
type BlockPutOption func(*BlockPutSettings) error
type BlockRmOption func(*BlockRmSettings) error
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论