hamt

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 11 Imported by: 4

README

go-hamt-ipld

Travis CI

A CHAMP HAMT implemented using ipld

Table of Contents

Examples

// TODO

Contribute

PRs are welcome!

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

License

MIT © Whyrusleeping

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxDepth = fmt.Errorf("attempted to traverse hamt beyond max depth")
View Source
var ErrNotFound = fmt.Errorf("not found")

Functions

This section is empty.

Types

type KV

type KV struct {
	Key   []byte
	Value *cbg.Deferred
}

func (*KV) MarshalCBOR

func (t *KV) MarshalCBOR(w io.Writer) error

func (*KV) UnmarshalCBOR

func (t *KV) UnmarshalCBOR(r io.Reader) error

type Node

type Node struct {
	Bitfield *big.Int   `refmt:"bf"`
	Pointers []*Pointer `refmt:"p"`
	// contains filtered or unexported fields
}

func LoadNode

func LoadNode(ctx context.Context, cs cbor.IpldStore, c cid.Cid, options ...Option) (*Node, error)

func NewNode

func NewNode(cs cbor.IpldStore, options ...Option) *Node

NewNode creates a new IPLD HAMT Node with the given store and given options

func (*Node) Copy

func (n *Node) Copy() *Node

func (*Node) Delete

func (n *Node) Delete(ctx context.Context, k string) error

func (*Node) Find

func (n *Node) Find(ctx context.Context, k string, out interface{}) error

func (*Node) FindRaw

func (n *Node) FindRaw(ctx context.Context, k string) ([]byte, error)

func (*Node) Flush

func (n *Node) Flush(ctx context.Context) error

func (*Node) ForEach

func (n *Node) ForEach(ctx context.Context, f func(k string, val interface{}) error) error

func (*Node) MarshalCBOR

func (t *Node) MarshalCBOR(w io.Writer) error

func (*Node) Set

func (n *Node) Set(ctx context.Context, k string, v interface{}) error

func (*Node) SetRaw

func (n *Node) SetRaw(ctx context.Context, k string, raw []byte) error

SetRaw sets key k to cbor bytes raw

func (*Node) UnmarshalCBOR

func (t *Node) UnmarshalCBOR(r io.Reader) error

type Option

type Option func(*Node)

Option is a function that configures the node

func UseHashFunction

func UseHashFunction(hash func([]byte) []byte) Option

UseHashFunction allows you to set the hash function used by the HAMT. It defaults to murmur3 but you should use sha256 when an attacker can pick the keys.

func UseTreeBitWidth

func UseTreeBitWidth(bitWidth int) Option

UseTreeBitWidth allows you to set the width of the HAMT tree in bits (from 1-8) via a customized hash function

type Pointer

type Pointer struct {
	KVs  []*KV   `refmt:"v,omitempty"`
	Link cid.Cid `refmt:"l,omitempty"`
	// contains filtered or unexported fields
}

func (*Pointer) MarshalCBOR

func (t *Pointer) MarshalCBOR(w io.Writer) error

func (*Pointer) UnmarshalCBOR

func (t *Pointer) UnmarshalCBOR(br io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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