hamt

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: MIT Imports: 16 Imported by: 21

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

func NewSerializationError added in v0.0.14

func NewSerializationError(err error) error

Types

type BasicCborIpldStore added in v0.0.14

type BasicCborIpldStore struct {
	Blocks blocks
	Atlas  *atlas.Atlas
}

BasicCborIpldStore is a simple CborIpldStore made from wrapping a blockstore.

func CSTFromBstore added in v0.0.10

func CSTFromBstore(bs Blockstore) *BasicCborIpldStore

func NewCborStore

func NewCborStore() *BasicCborIpldStore

func (*BasicCborIpldStore) Get added in v0.0.14

func (s *BasicCborIpldStore) Get(ctx context.Context, c cid.Cid, out interface{}) error

func (*BasicCborIpldStore) GetBlock added in v0.0.14

func (s *BasicCborIpldStore) GetBlock(ctx context.Context, cid cid.Cid) (block.Block, error)

func (*BasicCborIpldStore) Put added in v0.0.14

func (s *BasicCborIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error)

type Blockstore added in v0.0.10

type Blockstore interface {
	Get(cid.Cid) (block.Block, error)
	Put(block.Block) error
}

type CborIpldStore

type CborIpldStore interface {
	Get(ctx context.Context, c cid.Cid, out interface{}) error
	Put(ctx context.Context, v interface{}) (cid.Cid, error)
}

CborIpldStore is the ipld store interface required by the hamt.

type KV

type KV struct {
	Key   string
	Value *cbg.Deferred
}

func (*KV) MarshalCBOR added in v0.0.13

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

func (*KV) UnmarshalCBOR added in v0.0.13

func (t *KV) UnmarshalCBOR(br 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 CborIpldStore, c cid.Cid, options ...Option) (*Node, error)

func NewNode

func NewNode(cs CborIpldStore, 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) Flush

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

func (*Node) ForEach added in v0.0.11

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

func (*Node) MarshalCBOR added in v0.0.13

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) UnmarshalCBOR added in v0.0.13

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

type Option added in v0.0.13

type Option func(*Node)

Option is a function that configures the node

func UseTreeBitWidth added in v0.0.13

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 added in v0.0.13

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

func (*Pointer) UnmarshalCBOR added in v0.0.13

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

type SerializationError added in v0.0.14

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

func (SerializationError) Error added in v0.0.14

func (se SerializationError) Error() string

func (SerializationError) Is added in v0.0.14

func (se SerializationError) Is(o error) bool

func (SerializationError) Unwrap added in v0.0.14

func (se SerializationError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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