coreapi

package
v0.0.0-...-ce94876 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2019 License: MIT Imports: 58 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCoreAPI

func NewCoreAPI(n *core.IpfsNode, opts ...options.ApiOption) (coreiface.CoreAPI, error)

NewCoreAPI creates new instance of IPFS CoreAPI backed by go-ipfs Node.

Types

type BlockAPI

type BlockAPI CoreAPI

func (*BlockAPI) Get

func (api *BlockAPI) Get(ctx context.Context, p coreiface.Path) (io.Reader, error)

func (*BlockAPI) Put

func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.BlockPutOption) (coreiface.BlockStat, error)

func (*BlockAPI) Rm

func (api *BlockAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.BlockRmOption) error

func (*BlockAPI) Stat

type BlockStat

type BlockStat struct {
	// contains filtered or unexported fields
}

func (*BlockStat) Path

func (bs *BlockStat) Path() coreiface.ResolvedPath

func (*BlockStat) Size

func (bs *BlockStat) Size() int

type CoreAPI

type CoreAPI struct {
	// contains filtered or unexported fields
}

func (*CoreAPI) Block

func (api *CoreAPI) Block() coreiface.BlockAPI

Block returns the BlockAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Dag

func (api *CoreAPI) Dag() coreiface.DagAPI

Dag returns the DagAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Dht

func (api *CoreAPI) Dht() coreiface.DhtAPI

Dht returns the DhtAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Key

func (api *CoreAPI) Key() coreiface.KeyAPI

Key returns the KeyAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Name

func (api *CoreAPI) Name() coreiface.NameAPI

Name returns the NameAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Object

func (api *CoreAPI) Object() coreiface.ObjectAPI

Object returns the ObjectAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Pin

func (api *CoreAPI) Pin() coreiface.PinAPI

Pin returns the PinAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) PubSub

func (api *CoreAPI) PubSub() coreiface.PubSubAPI

PubSub returns the PubSubAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) ResolveNode

func (api *CoreAPI) ResolveNode(ctx context.Context, p coreiface.Path) (ipld.Node, error)

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.

func (*CoreAPI) Swarm

func (api *CoreAPI) Swarm() coreiface.SwarmAPI

Swarm returns the SwarmAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) Unixfs

func (api *CoreAPI) Unixfs() coreiface.UnixfsAPI

Unixfs returns the UnixfsAPI interface implementation backed by the go-ipfs node

func (*CoreAPI) WithOptions

func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, error)

WithOptions returns api with global options applied

type DagAPI

type DagAPI CoreAPI

func (*DagAPI) Batch

func (api *DagAPI) Batch(ctx context.Context) coreiface.DagBatch

Batch creates new DagBatch

func (*DagAPI) Get

func (api *DagAPI) Get(ctx context.Context, path coreiface.Path) (ipld.Node, error)

Get resolves `path` using Unixfs resolver, returns the resolved Node.

func (*DagAPI) Put

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.

func (*DagAPI) Tree

func (api *DagAPI) Tree(ctx context.Context, p coreiface.Path, opts ...caopts.DagTreeOption) ([]coreiface.Path, error)

Tree returns list of paths within a node specified by the path `p`.

type DhtAPI

type DhtAPI CoreAPI

func (*DhtAPI) FindPeer

func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (pstore.PeerInfo, error)

func (*DhtAPI) FindProviders

func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...caopts.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)

func (*DhtAPI) Provide

func (api *DhtAPI) Provide(ctx context.Context, path coreiface.Path, opts ...caopts.DhtProvideOption) error

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.

func (*KeyAPI) List

func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error)

List returns a list keys stored in keystore.

func (*KeyAPI) Remove

func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, error)

Remove removes keys from keystore. Returns ipns path of the removed key.

func (*KeyAPI) Rename

func (api *KeyAPI) Rename(ctx context.Context, oldName string, newName string, opts ...caopts.KeyRenameOption) (coreiface.Key, bool, error)

Rename renames `oldName` to `newName`. Returns the key and whether another key was overwritten, or an error.

func (*KeyAPI) Self

func (api *KeyAPI) Self(ctx context.Context) (coreiface.Key, error)
type Link struct {
	Name, Hash string
	Size       uint64
}

type NameAPI

type NameAPI CoreAPI

func (*NameAPI) Publish

Publish announces new IPNS name and returns the new IPNS entry.

func (*NameAPI) Resolve

func (api *NameAPI) Resolve(ctx context.Context, name string, opts ...caopts.NameResolveOption) (coreiface.Path, error)

Resolve attempts to resolve the newest version of the specified name and returns its path.

func (*NameAPI) Search

func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.NameResolveOption) (<-chan coreiface.IpnsResult, error)

type Node

type Node struct {
	Links []Link
	Data  string
}

type ObjectAPI

type ObjectAPI CoreAPI

func (*ObjectAPI) AppendData

func (api *ObjectAPI) AppendData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error)

func (*ObjectAPI) Data

func (api *ObjectAPI) Data(ctx context.Context, path coreiface.Path) (io.Reader, error)

func (*ObjectAPI) Diff

func (api *ObjectAPI) Diff(ctx context.Context, before coreiface.Path, after coreiface.Path) ([]coreiface.ObjectChange, error)

func (*ObjectAPI) Get

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 (*ObjectAPI) New

func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (ipld.Node, error)

func (*ObjectAPI) Put

func (api *ObjectAPI) RmLink(ctx context.Context, base coreiface.Path, link string) (coreiface.ResolvedPath, error)

func (*ObjectAPI) SetData

func (api *ObjectAPI) SetData(ctx context.Context, path coreiface.Path, r io.Reader) (coreiface.ResolvedPath, error)

func (*ObjectAPI) Stat

func (api *ObjectAPI) Stat(ctx context.Context, path coreiface.Path) (*coreiface.ObjectStat, error)

type PinAPI

type PinAPI CoreAPI

func (*PinAPI) Add

func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.PinAddOption) error

func (*PinAPI) Ls

func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) ([]coreiface.Pin, error)

func (*PinAPI) Rm

func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path) error

func (*PinAPI) Update

func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface.Path, opts ...caopts.PinUpdateOption) error

func (*PinAPI) Verify

func (api *PinAPI) Verify(ctx context.Context) (<-chan coreiface.PinStatus, error)

type PubSubAPI

type PubSubAPI CoreAPI

func (*PubSubAPI) Ls

func (api *PubSubAPI) Ls(ctx context.Context) ([]string, error)

func (*PubSubAPI) Peers

func (api *PubSubAPI) Peers(ctx context.Context, opts ...caopts.PubSubPeersOption) ([]peer.ID, error)

func (*PubSubAPI) Publish

func (api *PubSubAPI) Publish(ctx context.Context, topic string, data []byte) error

func (*PubSubAPI) Subscribe

type SwarmAPI

type SwarmAPI CoreAPI

func (*SwarmAPI) Connect

func (api *SwarmAPI) Connect(ctx context.Context, pi pstore.PeerInfo) error

func (*SwarmAPI) Disconnect

func (api *SwarmAPI) Disconnect(ctx context.Context, addr ma.Multiaddr) error

func (*SwarmAPI) KnownAddrs

func (api *SwarmAPI) KnownAddrs(context.Context) (map[peer.ID][]ma.Multiaddr, error)

func (*SwarmAPI) ListenAddrs

func (api *SwarmAPI) ListenAddrs(context.Context) ([]ma.Multiaddr, error)

func (*SwarmAPI) LocalAddrs

func (api *SwarmAPI) LocalAddrs(context.Context) ([]ma.Multiaddr, error)

func (*SwarmAPI) Peers

type UnixfsAPI

type UnixfsAPI CoreAPI

func (*UnixfsAPI) Add

Add builds a merkledag node from a reader, adds it to the blockstore, and returns the key representing that node.

func (*UnixfsAPI) Get

func (api *UnixfsAPI) Get(ctx context.Context, p coreiface.Path) (files.Node, error)

func (*UnixfsAPI) Ls

func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*ipld.Link, error)

Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format: `<link base58 hash> <link size in bytes> <link name>`

Directories

Path Synopsis
Package iface defines IPFS Core API which is a set of interfaces used to interact with IPFS nodes.
Package iface defines IPFS Core API which is a set of interfaces used to interact with IPFS nodes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL