node package - github.com/dms3-fs/go-ipld-format - Go Packages

node

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2016 License: MIT Imports: 3 Imported by: 0

README

go-ipld-node

Coverage Status Travis CI

go-ipld-node is the official 'node' interface for ipld, the interplanetary linked data format.

Table of Contents

Install

make install

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	// utf string name. should be unique per object
	Name string // utf8

	// cumulative size of target object
	Size uint64

	// multihash of the target object
	Cid *cid.Cid
}

Link represents an IPFS Merkle DAG Link between Nodes.

func MakeLink(n Node) (*Link, error)

MakeLink creates a link to the given node

func (*Link) GetNode

func (l *Link) GetNode(ctx context.Context, serv NodeGetter) (Node, error)

GetNode returns the MDAG Node that this link points to

type Node

type Node interface {
	// Resolve resolves a path through this node, stopping at any link boundary
	// and returning the object found as well as the remaining path to traverse
	Resolve(path []string) (interface{}, []string, error)

	// Tree lists all paths within the object under 'path', and up to the given depth.
	// To list the entire object (similar to `find .`) pass "" and -1
	Tree(path string, depth int) []string

	// ResolveLink is a helper function that calls resolve and asserts the
	// output is a link
	ResolveLink(path []string) (*Link, []string, error)

	Cid() *cid.Cid

	// Copy returns a deep copy of this node
	Copy() Node

	// Links is a helper function that returns all links within this object
	Links() []*Link

	// TODO: not sure if stat deserves to stay
	Stat() (*NodeStat, error)

	// Size returns the size in bytes of the serialized object
	Size() (uint64, error)

	// RawData marshals the node and returns the marshaled bytes
	RawData() []byte

	String() string
	Loggable() map[string]interface{}
}

type NodeGetter

type NodeGetter interface {
	Get(context.Context, *cid.Cid) (Node, error)
}

type NodeStat

type NodeStat struct {
	Hash           string
	NumLinks       int // number of links in link table
	BlockSize      int // size of the raw, encoded data
	LinksSize      int // size of the links segment
	DataSize       int // size of the data segment
	CumulativeSize int // cumulative size of object and its references
}

NodeStat is a statistics object for a Node. Mostly sizes.

func (NodeStat) String

func (ns NodeStat) String() string

Jump to

Keyboard shortcuts

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