ipfs

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddResult

type AddResult struct {
	Hash string `json:"Hash"`
	Size uint64 `json:"Size,string"`
}

AddResult contains result of AddResult command

func (*AddResult) String

func (a *AddResult) String() string

String implements fmt.Stringer interface

func (a *AddResult) ToLink(name string) Link

ToLink creates link from AddResult

type Cid

type Cid string

Cid represents a self-describing content adressed

func (Cid) Defined

func (c Cid) Defined() bool

Defined returns true if a Cid is defined Calling any other methods on an undefined Cid will result in undefined behavior.

func (Cid) MarshalJSON

func (c Cid) MarshalJSON() ([]byte, error)

MarshalJSON procudes a JSON representation of a Cid, which looks as follows:

{ "/": "<cid-string>" }

Note that this formatting comes from the IPLD specification (https://github.com/ipld/specs/tree/master/ipld)

func (Cid) String

func (c Cid) String() string

String returns the default string representation of a Cid.

func (c *Cid) ToLink(name string, size uint64) Link

ToLink creates link from Cid

func (*Cid) UnmarshalJSON

func (c *Cid) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the JSON representation of a Cid.

type IPFS

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

IPFS provides limited functionality to interact with the IPFS (https://ipfs.io)

func New

func New(url string) (*IPFS, error)

New creates new instance of IPFS from the provided url

func NewWithClient

func NewWithClient(uri string, c *http.Client) (*IPFS, error)

NewWithClient creates new instance of IPFS from the provided url and http.Client

func (*IPFS) Add

func (f *IPFS) Add(ctx context.Context, r io.Reader) (*AddResult, error)

Add a file to ipfs from the given reader, returns the hash of the added file

func (*IPFS) Cat

func (f *IPFS) Cat(ctx context.Context, path string) (io.ReadCloser, error)

Cat the content at the given path. Callers need to drain and close the returned reader after usage.

func (*IPFS) CatBytes

func (f *IPFS) CatBytes(ctx context.Context, path string) (bs []byte, err error)

CatBytes returns the content bytes at the given path.

func (f *IPFS) DagGetLinks(ctx context.Context, cid Cid) ([]Link, error)

DagGetLinks gets directory links.

func (f *IPFS) DagPutLinks(ctx context.Context, links []Link) (Cid, error)

DagPutLinks puts directory containing links and returns Cid of directory.

func (*IPFS) ObjectStat

func (f *IPFS) ObjectStat(ctx context.Context, path string) (*ObjectStat, error)

ObjectStat returns information about the dag node

type Link struct {
	// multihash of the target object
	Cid Cid `json:"Cid"`
	// utf string name. should be unique per object
	Name string `json:"Name"`
	// cumulative size of target object
	Size uint64 `json:"Size"`
}

Link represents an IPFS Merkle DAG Link between Nodes.

type ObjectStat

type ObjectStat struct {
	Hash           string `json:"Hash"`
	NumLinks       uint64 `json:"NumLinks"`
	BlockSize      uint64 `json:"BlockSize"`
	LinksSize      uint64 `json:"LinksSize"`
	DataSize       uint64 `json:"DataSize"`
	CumulativeSize uint64 `json:"CumulativeSize"`
}

ObjectStat provides information about dag nodes

Jump to

Keyboard shortcuts

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