utils

package
v0.0.0-...-6f8bca6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeRaw = cid.Raw
	TypeDAG = 0x70
)
View Source
const (
	FieldTypeInt   = 0
	FieldTypeBytes = 1
	FieldTypeMsg   = 2
)

Variables

This section is empty.

Functions

func DecodeLink(b *bytes.Reader) (cid.Cid, error)

func DigestForLog

func DigestForLog(digest Digest) string

func DigestToHumanString

func DigestToHumanString(d Digest) string

func DigestToProto

func DigestToProto(d Digest) *pb.Digest

func EncodeField

func EncodeField(b *bytes.Buffer, f *Field) error
func EncodeLink(b *bytes.Buffer, link cid.Cid) error

func FormatDigest

func FormatDigest(digest Digest, format string) string

func PrintPath

func PrintPath(path Path) string

func PrintSelector

func PrintSelector(s Selector) string

func ReadUint64

func ReadUint64(b *bytes.Reader) (uint64, error)

func SerializeDAGNode

func SerializeDAGNode(node *DAGNode) ([]byte, error)

func WriteUint64

func WriteUint64(b *bytes.Buffer, i uint64) error

Types

type DAGNode

type DAGNode struct {
	Bytes []byte
	Links []cid.Cid
}

func ParseDAGNode

func ParseDAGNode(b []byte) (*DAGNode, error)

type Digest

type Digest = multihash.Multihash

func ComputeDigest

func ComputeDigest(b []byte) Digest

func DigestFromProto

func DigestFromProto(d *pb.Digest) Digest

func ParseDigest

func ParseDigest(s string) (Digest, error)

type DigestArray

type DigestArray [64]byte

func DigestToArray

func DigestToArray(digest multihash.Multihash) DigestArray

Convert to a fixed size array. Only to be used for in-memory caching.

type Field

type Field struct {
	ID   uint64
	Type uint64

	UintValue  uint64
	BytesValue []byte
}

func DecodeField

func DecodeField(b *bytes.Reader) (*Field, error)

type NodeID

type NodeID struct {
	Root cid.Cid
	Path Path
}

type Path

type Path []Selector

func ParsePath

func ParsePath(s string) (Path, error)

type Selector

type Selector uint

Index of the link to follow

func ParseSelector

func ParseSelector(s string) (Selector, error)

Parse a selector of the form "1"

Jump to

Keyboard shortcuts

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