一起来读源码233-Ipfs 第三方库:interface-go-ipfs-core

摘要

 

详情

interface-go-ipfs-core

定义接口

BlockStat:块状态

类型说明

Size() int

块尺寸

Path() path.Resolved

块路径

BlockAPI: 块api

类型说明

Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error)

放入块

Get(context.Context, path.Path) (io.Reader, error)

根据路径拿块内容

Rm(context.Context, path.Path, ...options.BlockRmOption) error

删除路径

Stat(context.Context, path.Path) (BlockStat, error)

返回块状态

CoreAPI:核心api

类型说明

Unixfs() UnixfsAPI

 

Block() BlockAPI

 

Dag() APIDagService

 

Name() NameAPI

 

Key() KeyAPI

 

Pin() PinAPI

 

Object() ObjectAPI

 

Dht() DhtAPI

 

Swarm() SwarmAPI

 

PubSub() PubSubAPI

 

ResolvePath(context.Context, path.Path) (path.Resolved, error)

 

ResolveNode(context.Context, path.Path) (ipld.Node, error)

 

WithOptions(...options.ApiOption) (CoreAPI, error)

 

APIDagService:dagserv

类型说明

ipld.DAGService

 

Pinning() ipld.NodeAdder

 

DhtAPI

类型说明

FindPeer(context.Context, peer.ID) (peer.AddrInfo, error)

 

FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan peer.AddrInfo, error)

 

Provide(context.Context, path.Path, ...options.DhtProvideOption) error

 

Key

类型说明

Name() string

key的名字

Path() path.Path

路径

ID() peer.ID

id

KeyAPI

类型说明

Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error)

 

Rename(ctx context.Context, oldName string, newName string, opts ...options.KeyRenameOption) (Key, bool, error)

 

List(ctx context.Context) ([]Key, error)

 

Self(ctx context.Context) (Key, error)

 

Remove(ctx context.Context, name string) (Key, error)

 

IpnsEntry

类型说明

Name() string

 

Value() path.Path

 

NameAPI

类型说明

Publish(ctx context.Context, path path.Path, opts ...options.NamePublishOption) (IpnsEntry, error)

 

Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (path.Path, error)

 

Search(ctx context.Context, name string, opts ...options.NameResolveOption) (<-chan IpnsResult, error)

 

定义类型

类型说明

type ChangeType int

 

定义全局变量

变量名类型

ErrIsDir

error

errors.New("this dag node is a directory")

ErrNotFile

error

errors.New("this dag node is not a regular file")

ErrOffline

error

errors.New("this action must be run in online mode, try running 'ipfs daemon' first")

ErrNotSupported

error

errors.New("operation not supported")

DiffAdd

ChangeType

0.添加

DiffRemove

ChangeType

1.删除

DiffMod

ChangeType

2.修改

定义类

IpnsResult

类型说明

path.Path

 

Err error

 

ObjectStat

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值