merkledag

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package merkledag is a generated protocol buffer package.

It is generated from these files:

data.proto

It has these top-level messages:

PBData

Package merkledag is a generated protocol buffer package.

It is generated from these files:
	node.proto

It has these top-level messages:
	PBLink
	PBNode

Index

Constants

This section is empty.

Variables

View Source
var ErrIsDir = errors.New("this dag node is a directory")
View Source
var PBData_DataType_name = map[int32]string{
	0: "Raw",
	1: "Directory",
	2: "File",
}
View Source
var PBData_DataType_value = map[string]int32{
	"Raw":       0,
	"Directory": 1,
	"File":      2,
}

Functions

func FilePBData

func FilePBData(data []byte) []byte

func FolderPBData

func FolderPBData() []byte

func NewDagReader

func NewDagReader(n *Node, serv *DAGService) (io.Reader, error)

func WrapData

func WrapData(b []byte) []byte

Types

type DAGService

type DAGService struct {
	Blocks *bserv.BlockService
}

DAGService is an IPFS Merkle DAG service. - the root is virtual (like a forest) - stores nodes' data in a BlockService TODO: should cache Nodes that are in memory, and be

able to free some of them when vm pressure is high

func (*DAGService) Add

func (n *DAGService) Add(nd *Node) (u.Key, error)

Add adds a node to the DAGService, storing the block in the BlockService

func (*DAGService) AddRecursive

func (n *DAGService) AddRecursive(nd *Node) error

func (*DAGService) Get

func (n *DAGService) Get(k u.Key) (*Node, error)

Get retrieves a node from the DAGService, fetching the block in the BlockService

type DagReader

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

DagReader provides a way to easily read the data contained in a dag.

func (*DagReader) Read

func (dr *DagReader) Read(b []byte) (int, error)
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
	Hash mh.Multihash

	// a ptr to the actual node for graph manipulation
	Node *Node
}

Link represents an IPFS Merkle DAG Link between Nodes.

type Node

type Node struct {
	Links []*Link
	Data  []byte
	// contains filtered or unexported fields
}

Node represents a node in the IPFS Merkle DAG. nodes have opaque data and a set of navigable links.

func Decoded

func Decoded(encoded []byte) (*Node, error)

Decoded decodes raw data and returns a new Node instance.

func (n *Node) AddNodeLink(name string, that *Node) error

AddNodeLink adds a link to another node.

func (*Node) Encoded

func (n *Node) Encoded(force bool) ([]byte, error)

Encoded returns the encoded raw data version of a Node instance. It may use a cached encoded version, unless the force flag is given.

func (*Node) Key

func (n *Node) Key() (u.Key, error)

Key returns the Multihash as a key, for maps.

func (*Node) Marshal

func (n *Node) Marshal() ([]byte, error)

Marshal encodes a *Node instance into a new byte slice. The conversion uses an intermediate PBNode.

func (*Node) MarshalTo

func (n *Node) MarshalTo(encoded []byte) error

MarshalTo encodes a *Node instance into a given byte slice. The conversion uses an intermediate PBNode.

func (*Node) Multihash

func (n *Node) Multihash() (mh.Multihash, error)

Multihash hashes the encoded data of this node.

func (*Node) Size

func (n *Node) Size() (uint64, error)

Size returns the total size of the data addressed by node, including the total sizes of references.

func (*Node) Unmarshal

func (n *Node) Unmarshal(encoded []byte) error

Unmarshal decodes raw data into a *Node instance. The conversion uses an intermediate PBNode.

type NodeMap

type NodeMap map[u.Key]*Node

NodeMap maps u.Keys to Nodes. We cannot use []byte/Multihash for keys :( so have to convert Multihash bytes to string (u.Key)

type PBData

type PBData struct {
	Type             *PBData_DataType `protobuf:"varint,1,req,enum=merkledag.PBData_DataType" json:"Type,omitempty"`
	Data             []byte           `protobuf:"bytes,2,opt" json:"Data,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

func (*PBData) GetData

func (m *PBData) GetData() []byte

func (*PBData) GetType

func (m *PBData) GetType() PBData_DataType

func (*PBData) ProtoMessage

func (*PBData) ProtoMessage()

func (*PBData) Reset

func (m *PBData) Reset()

func (*PBData) String

func (m *PBData) String() string

type PBData_DataType

type PBData_DataType int32
const (
	PBData_Raw       PBData_DataType = 0
	PBData_Directory PBData_DataType = 1
	PBData_File      PBData_DataType = 2
)

func (PBData_DataType) Enum

func (x PBData_DataType) Enum() *PBData_DataType

func (PBData_DataType) String

func (x PBData_DataType) String() string

func (*PBData_DataType) UnmarshalJSON

func (x *PBData_DataType) UnmarshalJSON(data []byte) error
type PBLink struct {
	// multihash of the target object
	Hash []byte `protobuf:"bytes,1,opt" json:"Hash,omitempty"`
	// utf string name. should be unique per object
	Name *string `protobuf:"bytes,2,opt" json:"Name,omitempty"`
	// cumulative size of target object
	Tsize            *uint64 `protobuf:"varint,3,opt" json:"Tsize,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

An IPFS MerkleDAG Link

func NewPopulatedPBLink(r randyNode, easy bool) *PBLink

func (*PBLink) Equal

func (this *PBLink) Equal(that interface{}) bool

func (*PBLink) GetHash

func (m *PBLink) GetHash() []byte

func (*PBLink) GetName

func (m *PBLink) GetName() string

func (*PBLink) GetTsize

func (m *PBLink) GetTsize() uint64

func (*PBLink) GoString

func (this *PBLink) GoString() string

func (*PBLink) Marshal

func (m *PBLink) Marshal() (data []byte, err error)

func (*PBLink) MarshalTo

func (m *PBLink) MarshalTo(data []byte) (n int, err error)

func (*PBLink) ProtoMessage

func (*PBLink) ProtoMessage()

func (*PBLink) Reset

func (m *PBLink) Reset()

func (*PBLink) Size

func (m *PBLink) Size() (n int)

func (*PBLink) String

func (this *PBLink) String() string

func (*PBLink) Unmarshal

func (m *PBLink) Unmarshal(data []byte) error

func (*PBLink) VerboseEqual

func (this *PBLink) VerboseEqual(that interface{}) error

type PBNode

type PBNode struct {
	// refs to other objects
	Links []*PBLink `protobuf:"bytes,2,rep" json:"Links,omitempty"`
	// opaque user data
	Data             []byte `protobuf:"bytes,1,opt" json:"Data,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

An IPFS MerkleDAG Node

func NewPopulatedPBNode

func NewPopulatedPBNode(r randyNode, easy bool) *PBNode

func (*PBNode) Equal

func (this *PBNode) Equal(that interface{}) bool

func (*PBNode) GetData

func (m *PBNode) GetData() []byte
func (m *PBNode) GetLinks() []*PBLink

func (*PBNode) GoString

func (this *PBNode) GoString() string

func (*PBNode) Marshal

func (m *PBNode) Marshal() (data []byte, err error)

func (*PBNode) MarshalTo

func (m *PBNode) MarshalTo(data []byte) (n int, err error)

func (*PBNode) ProtoMessage

func (*PBNode) ProtoMessage()

func (*PBNode) Reset

func (m *PBNode) Reset()

func (*PBNode) Size

func (m *PBNode) Size() (n int)

func (*PBNode) String

func (this *PBNode) String() string

func (*PBNode) Unmarshal

func (m *PBNode) Unmarshal(data []byte) error

func (*PBNode) VerboseEqual

func (this *PBNode) VerboseEqual(that interface{}) error

Jump to

Keyboard shortcuts

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