merklelog

package
v0.0.0-...-f6f957e Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Constructor

func Constructor(params json.RawMessage, mkSchema schema.Factory) (schema.Schema, error)

Constructor is a schema constructor

func Get

func Get(ctx context.Context, rs schema.RO, s State, i Pos) (blobcache.CID, error)

Get retrieves the CID at index i in the log.

func Includes

func Includes(ctx context.Context, rs schema.RO, a, b State) (bool, error)

Includes returns (true, nil) if a references all of the data in b. Includes returns (false, nil) if a cannot reference all of b's data. Includes returns (false, err) if an error occurs.

Types

type CID

type CID = blobcache.CID

type Iterator

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

func NewIterator

func NewIterator(state State, s schema.RO, beg, end Pos) *Iterator

func (*Iterator) Next

func (it *Iterator) Next(ctx context.Context, dst *CID) error

type Params

type Params struct {
	X           blobcache.SchemaSpec `json:"x"`
	MaxRootSize int                  `json:"maxRootSize"`
}

type Pos

type Pos = uint64

Pos is a position in the merkle log.

type Schema

type Schema struct {
	X           schema.Schema
	MaxRootSize int
}

func (Schema) ValidateChange

func (sch Schema) ValidateChange(ctx context.Context, change schema.Change) error

type State

type State struct {
	// Levels are the rightmost nodes of a binary merkle tree.
	// New entries are always added to level 0, and if there is already a value at that level
	// then it is hashed with the new value to produce a new node, which is then inserted at level 1.
	// This process is repeated until there is no more space at the current level, and a new level is created.
	Levels []CID
}

func Parse

func Parse(data []byte) (State, error)

func (*State) Append

func (s *State) Append(ctx context.Context, rws schema.RW, x blobcache.CID) error

Append appends a new CID to the state, it updates the state in place.

func (State) Len

func (s State) Len() (ret Pos)

Len returns the number of CIDs included in the state.

func (State) Marshal

func (s State) Marshal(out []byte) []byte

func (*State) Unmarshal

func (s *State) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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