Documentation ¶
Overview ¶
Package coreapi provides direct access to the core commands in IPFS. If you are embedding IPFS directly in your Go program, this package is the public interface you should use to read and write files or otherwise control IPFS.
If you are running IPFS as a separate process, you should use `go-ipfs-api` to work with it via HTTP. As we finalize the interfaces here, `go-ipfs-api` will transparently adopt them so you can use the same code with either package.
**NOTE: this package is experimental.** `go-ipfs` has mainly been developed as a standalone application and library-style use of this package is still new. Interfaces here aren't yet completely stable.
Index ¶
- func NewCoreAPI(n *core.IpfsNode) coreiface.CoreAPI
- type BlockAPI
- func (api *BlockAPI) Get(ctx context.Context, p coreiface.Path) (io.Reader, error)
- func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.BlockPutOption) (coreiface.BlockStat, error)
- func (api *BlockAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.BlockRmOption) error
- func (api *BlockAPI) Stat(ctx context.Context, p coreiface.Path) (coreiface.BlockStat, error)
- type BlockStat
- type CoreAPI
- func (api *CoreAPI) Block() coreiface.BlockAPI
- func (api *CoreAPI) Dag() coreiface.DagAPI
- func (api *CoreAPI) Dht() coreiface.DhtAPI
- func (api *CoreAPI) Key() coreiface.KeyAPI
- func (api *CoreAPI) Name() coreiface.NameAPI
- func (api *CoreAPI) Object() coreiface.ObjectAPI
- func (api *CoreAPI) Pin() coreiface.PinAPI
- func (api *CoreAPI) PubSub() coreiface.PubSubAPI
- func (api *CoreAPI) ResolveNode(ctx context.Context, p coreiface.Path) (ipld.Node, error)
- func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreiface.ResolvedPath, error)
- func (api *CoreAPI) Swarm() coreiface.SwarmAPI
- func (api *CoreAPI) Unixfs() coreiface.UnixfsAPI
- type DagAPI
- func (api *DagAPI) Batch(ctx context.Context) coreiface.DagBatch
- func (api *DagAPI) Get(ctx context.Context, path coreiface.Path) (ipld.Node, error)
- func (api *DagAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.DagPutOption) (coreiface.ResolvedPath, error)
- func (api *DagAPI) Tree(ctx context.Context, p coreiface.Path, opts ...caopts.DagTreeOption) ([]coreiface.Path, error)
- type DhtAPI
- func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (pstore.PeerInfo, error)
- func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...caopts.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
- func (api *DhtAPI) Provide(ctx context.Context, path coreiface.Path, opts ...caopts.DhtProvideOption) error
- type KeyAPI
- func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.KeyGenerateOption) (coreiface.Key, error)
- func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error)
- func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, error)
- func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, ...) (coreiface.Key, bool, error)
- func (api *KeyAPI) Self(ctx context.Context) (coreiface.Key, error)
- type Link
- type NameAPI
- func (api *NameAPI) Publish(ctx context.Context, p coreiface.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error)
- func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (coreiface.Path, error)
- func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.NameResolveOption) (<-chan coreiface.IpnsResult, error)
- type Node
- type ObjectAPI
- func (api *ObjectAPI) AddLink(ctx context.Context, base coreiface.Path, name string, child coreiface.Path, ...) (coreiface.ResolvedPath, error)
- func (api *ObjectAPI) AppendData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error)
- func (api *ObjectAPI) Data(ctx context.Context, path coreiface.Path) (io.Reader, error)
- func (api *ObjectAPI) Diff(ctx context.Context, before coreiface.Path, after coreiface.Path) ([]coreiface.ObjectChange, error)
- func (api *ObjectAPI) Get(ctx context.Context, path coreiface.Path) (ipld.Node, error)
- func (api *ObjectAPI) Links(ctx context.Context, path coreiface.Path) ([]*ipld.Link, error)
- func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (ipld.Node, error)
- func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.ObjectPutOption) (coreiface.ResolvedPath, error)
- func (api *ObjectAPI) RmLink(ctx context.Context, base coreiface.Path, link string) (coreiface.ResolvedPath, error)
- func (api *ObjectAPI) SetData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error)
- func (api *ObjectAPI) Stat(ctx context.Context, path coreiface.Path) (*coreiface.ObjectStat, error)
- type PinAPI
- func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.PinAddOption) error
- func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) ([]coreiface.Pin, error)
- func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path) error
- func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface.Path, ...) error
- func (api *PinAPI) Verify(ctx context.Context) (<-chan coreiface.PinStatus, error)
- type PubSubAPI
- func (api *PubSubAPI) Ls(ctx context.Context) ([]string, error)
- func (api *PubSubAPI) Peers(ctx context.Context, opts ...caopts.PubSubPeersOption) ([]peer.ID, error)
- func (api *PubSubAPI) Publish(ctx context.Context, topic string, data []byte) error
- func (api *PubSubAPI) Subscribe(ctx context.Context, topic string, opts ...caopts.PubSubSubscribeOption) (coreiface.PubSubSubscription, error)
- type SwarmAPI
- func (api *SwarmAPI) Connect(ctx context.Context, pi pstore.PeerInfo) error
- func (api *SwarmAPI) Disconnect(ctx context.Context, addr ma.Multiaddr) error
- func (api *SwarmAPI) KnownAddrs(context.Context) (map[peer.ID][]ma.Multiaddr, error)
- func (api *SwarmAPI) ListenAddrs(context.Context) ([]ma.Multiaddr, error)
- func (api *SwarmAPI) LocalAddrs(context.Context) ([]ma.Multiaddr, error)
- func (api *SwarmAPI) Peers(context.Context) ([]coreiface.ConnectionInfo, error)
- type UnixfsAPI
- func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options.UnixfsAddOption) (coreiface.ResolvedPath, error)
- func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (coreiface.UnixfsFile, error)
- func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*ipld.Link, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockAPI ¶
type BlockAPI CoreAPI
type BlockStat ¶
type BlockStat struct {
// contains filtered or unexported fields
}
func (*BlockStat) Path ¶
func (bs *BlockStat) Path() coreiface.ResolvedPath
type CoreAPI ¶
type CoreAPI struct {
// contains filtered or unexported fields
}
func (*CoreAPI) Block ¶
Block returns the BlockAPI interface implementation backed by the go-ipfs node
func (*CoreAPI) Object ¶
Object returns the ObjectAPI interface implementation backed by the go-ipfs node
func (*CoreAPI) PubSub ¶
PubSub returns the PubSubAPI interface implementation backed by the go-ipfs node
func (*CoreAPI) ResolveNode ¶
ResolveNode resolves the path `p` using Unixfs resolver, gets and returns the resolved Node.
func (*CoreAPI) ResolvePath ¶
func (api *CoreAPI) ResolvePath(ctx context.Context, p coreiface.Path) (coreiface.ResolvedPath, error)
ResolvePath resolves the path `p` using Unixfs resolver, returns the resolved path.
type DagAPI ¶ added in v0.4.14
type DagAPI CoreAPI
func (*DagAPI) Get ¶ added in v0.4.14
Get resolves `path` using Unixfs resolver, returns the resolved Node.
func (*DagAPI) Put ¶ added in v0.4.14
func (api *DagAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.DagPutOption) (coreiface.ResolvedPath, error)
Put inserts data using specified format and input encoding. Unless used with `WithCodes` or `WithHash`, the defaults "dag-cbor" and "sha256" are used. Returns the path of the inserted data.
type KeyAPI ¶
type KeyAPI CoreAPI
func (*KeyAPI) Generate ¶
func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.KeyGenerateOption) (coreiface.Key, error)
Generate generates new key, stores it in the keystore under the specified name and returns a base58 encoded multihash of its public key.
type NameAPI ¶
type NameAPI CoreAPI
func (*NameAPI) Publish ¶
func (api *NameAPI) Publish(ctx context.Context, p coreiface.Path, opts ...caopts.NamePublishOption) (coreiface.IpnsEntry, error)
Publish announces new IPNS name and returns the new IPNS entry.
type ObjectAPI ¶
type ObjectAPI CoreAPI
func (*ObjectAPI) AppendData ¶
func (*ObjectAPI) Put ¶
func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.ObjectPutOption) (coreiface.ResolvedPath, error)
type SwarmAPI ¶
type SwarmAPI CoreAPI
func (*SwarmAPI) Disconnect ¶
func (*SwarmAPI) KnownAddrs ¶
func (*SwarmAPI) ListenAddrs ¶
func (*SwarmAPI) LocalAddrs ¶
type UnixfsAPI ¶
type UnixfsAPI CoreAPI
func (*UnixfsAPI) Add ¶
func (api *UnixfsAPI) Add(ctx context.Context, files files.File, opts ...options.UnixfsAddOption) (coreiface.ResolvedPath, error)
Add builds a merkledag node from a reader, adds it to the blockstore, and returns the key representing that node.