sharray

package module
v0.0.0-...-e419318 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 6 Imported by: 0

README

Sharray

A sharded array, on ipld.

Goals:

  • datastructure for a list of CIDs with minimal overhead
  • efficient merkle proofs
    • As small as is reasonably possible
    • Fast to compute
    • These will be primarily for Filecoin light clients
  • fast
  • ipld native

Non-goals:

  • Easy random insertions
  • Supporting removal of items

Structure

Each sharray has a given width. Each of the leaf nodes contains at most that many elements, and only the final node may have fewer. When the number of leaf nodes grows to be more than the given width, an additional layer is added. Each node has a field specifying which layer the node is in the tree.

Single Layer:
[ H:0; 1, 2, 3, 4]


Two Layer:
[ H:1; A, B ] 

A = [ H:0; 1, 2, 3, 4], B = [ H:0; 5, 6, 7, 8]

Three Layer:

[ H:2; X, Y]

X = [ H:1; A, B, C, D], Y = [ H:1, E, F, G, H]

A = [ H:0; 1, 2, 3, 4] .... (and so on)
License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotCid = fmt.Errorf("item in intermediate sharray node was not a Cid")
View Source
var ErrOutOfRange = fmt.Errorf("out of range")

Functions

func Build

func Build(ctx context.Context, width int, items []interface{}, cst *hamt.CborIpldStore) (cid.Cid, error)

Types

type Sharray

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

func Load

func Load(ctx context.Context, c cid.Cid, width int, cst *hamt.CborIpldStore) (*Sharray, error)

func (*Sharray) ForEach

func (s *Sharray) ForEach(ctx context.Context, f func(interface{}) error) error

func (*Sharray) Get

func (s *Sharray) Get(ctx context.Context, i int) (interface{}, error)

func (*Sharray) Len

func (s *Sharray) Len(ctx context.Context) (int, error)

Jump to

Keyboard shortcuts

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