cells

package
v0.0.0-...-52fa803 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CellPrefix = cid.Prefix{
	Version:  1,
	Codec:    0x70bc,
	MhType:   mh.SHA2_256,
	MhLength: 32,
}

CellPrefix - Binary cell CID prefix.

View Source
var UndefCID = CID{}

UndefCID - Alias to an empty content ID.

Functions

func Marshal

func Marshal(cell Cell) (body []byte, err error)

Marshal - Marshals cell as byte array.

func MarshalJSON

func MarshalJSON(cell Cell) (_ []byte, err error)

MarshalJSON - Marshals cell as JSON.

func ToHex

func ToHex(cell Cell) (body []byte, err error)

ToHex - Encodes binary cell to hex.

func Unmarshal

func Unmarshal(cell MutableCell, body []byte) error

Unmarshal - Unmarshals cell from byte array.

Types

type BinaryCell

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

BinaryCell - Binary representation of cell.

func New

func New(op ID, memory []byte, children ...Cell) *BinaryCell

New - Creates new binary cell.

func Op

func Op(op ID, ops ...Cell) *BinaryCell

Op - Creates new binary cell.

func Root

func Root(ops []Cell) *BinaryCell

Root - Creates new binary cell.

func TODO

func TODO() *BinaryCell

TODO - Returns empty cell.

func UnmarshalBinary

func UnmarshalBinary(body []byte) (c *BinaryCell, err error)

UnmarshalBinary - Unmarshals new binary cell.

func (*BinaryCell) AddChildren

func (cell *BinaryCell) AddChildren(children ...Cell)

AddChildren - Appends new children operation.

func (*BinaryCell) CID

func (cell *BinaryCell) CID() (_ CID)

CID - Computes marshaled cell cid.

func (*BinaryCell) Checksum

func (cell *BinaryCell) Checksum() (_ ID, err error)

Checksum - Computes marshalled xxhash64 of cell content id.

func (*BinaryCell) Child

func (cell *BinaryCell) Child(n int) Cell

Child - Child cell by index.

func (*BinaryCell) ChildrenSize

func (cell *BinaryCell) ChildrenSize() int

ChildrenSize - Amount of children.

func (*BinaryCell) Marshal

func (cell *BinaryCell) Marshal() (_ []byte, err error)

Marshal - Marshals cell.

func (*BinaryCell) MarshalJSON

func (cell *BinaryCell) MarshalJSON() (_ []byte, err error)

MarshalJSON - Marshals cell as JSON.

func (*BinaryCell) Memory

func (cell *BinaryCell) Memory() []byte

Memory - Operation memory.

func (*BinaryCell) OpCode

func (cell *BinaryCell) OpCode() ID

OpCode - Operation ID.

func (*BinaryCell) SetChildren

func (cell *BinaryCell) SetChildren(children []Cell)

SetChildren - Set operation children.

func (*BinaryCell) SetMemory

func (cell *BinaryCell) SetMemory(memory []byte)

SetMemory - Set operation memory.

func (*BinaryCell) SetOpCode

func (cell *BinaryCell) SetOpCode(opCode ID)

SetOpCode - Sets operation ID.

func (*BinaryCell) String

func (cell *BinaryCell) String() string

String - Prints to string.

type CID

type CID struct {
	cid.Cid
}

CID - Content ID wrapper.

func DecodeCID

func DecodeCID(v string) (_ CID, err error)

DecodeCID - Decodes CID.

func NewCID

func NewCID(codecType uint64, mhash mh.Multihash) CID

NewCID - Creates new wrapped content ID v1 for codec and hash.

func NewCIDFromHash

func NewCIDFromHash(codecType uint64, hash []byte, hashType uint64) CID

NewCIDFromHash - Creates new wrapped content ID v1 for codec and hash.

func ParseCID

func ParseCID(v interface{}) (_ CID, err error)

ParseCID - Parses CID.

func SumCID

func SumCID(prefix cid.Prefix, body []byte) (_ CID, err error)

SumCID - Sums content id and wraps.

func WrapCID

func WrapCID(c cid.Cid) CID

WrapCID - Wraps content id.

func (*CID) Defined

func (c *CID) Defined() bool

Defined - Returns true if CID is not empty.

func (CID) Digest

func (c CID) Digest() []byte

Digest - Returns 32 bytes of hash.

func (CID) MarshalJSON

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

MarshalJSON - Marshals the cid as string.

func (*CID) UnmarshalJSON

func (c *CID) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON - Parses the JSON string representation of a cid.

type Cell

type Cell interface {
	// CID - Operation CID.
	CID() CID

	// OpCode - Operation ID.
	OpCode() ID

	// Memory - Operation memory.
	Memory() []byte

	// Child - Child cell by index.
	Child(int) Cell

	// ChildrenSize - Amount of children.
	ChildrenSize() int

	// Marshal - Marshals cell.
	Marshal() ([]byte, error)

	fmt.Stringer
}

Cell - Operation cell interface.

func FromHex

func FromHex(src []byte) (_ Cell, err error)

FromHex - Decodes cell from hex encoded binary cell.

func FromHexString

func FromHexString(src string) (_ Cell, err error)

FromHexString - Decodes cell from hex encoded binary cell.

func Ops

func Ops(ops ...Cell) []Cell

Ops - Returns ops.

type CellPrinter

type CellPrinter struct {
	Cell
}

CellPrinter - Cell pretty printer.

func NewChildrenPrinter

func NewChildrenPrinter(cell Cell) (res []*CellPrinter)

NewChildrenPrinter - Creates new cell pretty printer.

func NewPrinter

func NewPrinter(cell Cell) *CellPrinter

NewPrinter - Creates new cell pretty printer.

func (*CellPrinter) MarshalJSON

func (p *CellPrinter) MarshalJSON() (_ []byte, err error)

MarshalJSON - Marshals cell as JSON.

type ID

type ID uint64

ID - Cell of an ID registered on-chain.

func DecodeID

func DecodeID(body []byte) ID

DecodeID - Decodes cell ID from byte array.

func NewID

func NewID(body []byte) ID

NewID - Creates new cell ID from bytes.

func NewIDFromString

func NewIDFromString(body string) ID

NewIDFromString - Creates new cell ID from string.

func ParseID

func ParseID(body string) (_ ID, err error)

ParseID - Parses cell ID from a string.

func Register

func Register(code ID, name string) ID

Register - Registers op code. Panics if code is not unique.

func (ID) Bytes

func (id ID) Bytes() []byte

Bytes - Returns cell ID in bytes format.

func (ID) Encode

func (id ID) Encode() string

Encode - Returns cell ID in base32 format.

func (ID) MarshalJSON

func (id ID) MarshalJSON() (_ []byte, err error)

MarshalJSON - Marshals ID as JSON string.

func (ID) String

func (id ID) String() string

String - Returns cell ID in string format.

type MutableCell

type MutableCell interface {
	Cell

	// AddChildren - Adds children.
	AddChildren(...Cell)

	// SetOpCode - Sets operation ID.
	SetOpCode(ID)

	// SetMemory - Set operation memory.
	SetMemory([]byte)

	// SetChildren - Set operation children.
	SetChildren([]Cell)
}

MutableCell - Mutable cell interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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