storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package storage provides implementations and shared components for tessera storage backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Integrate

func Integrate(ctx context.Context, getTiles func(ctx context.Context, tileIDs []TileID, treeSize uint64) ([]*api.HashTile, error), fromSize uint64, leafHashes [][]byte) (newSize uint64, rootHash []byte, tiles map[TileID]*api.HashTile, err error)

Types

type FlushFunc

type FlushFunc func(ctx context.Context, entries []*tessera.Entry) error

FlushFunc is the signature of a function which will receive the slice of queued entries. Normally, this function would be provided by storage implementations. It's important to note that the implementation MUST call each entry's MarshalBundleData function before attempting to integrate it into the tree. See the comment on Entry.MarshalBundleData for further info.

type Queue

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

Queue knows how to queue up a number of entries in order, taking care of deduplication as they're added.

When the buffered queue grows past a defined size, or the age of the oldest entry in the queue reaches a defined threshold, the queue will call a provided FlushFunc with a slice containing all queued entries in the same order as they were added.

If multiple identical entries are added to the queue between flushes, the queue will deduplicate them by passing only the first through to the FlushFunc, and returning the index assigned to that entry to all duplicate add calls. Note that this deduplication only applies to "in-flight" entries currently in the queue; entries added after a flush will not be deduped against those added before the flush.

func NewQueue

func NewQueue(ctx context.Context, maxAge time.Duration, maxSize uint, f FlushFunc) *Queue

NewQueue creates a new queue with the specified maximum age and size.

The provided FlushFunc will be called with a slice containing the contents of the queue, in the same order as they were added, when either the oldest entry in the queue has been there for maxAge, or the size of the queue reaches maxSize.

func (*Queue) Add

Add places e into the queue, and returns a func which may be called to retrieve the assigned index.

type SequencedEntry

type SequencedEntry struct {
	// BundleData is the entry's data serialised into the correct format for appending to an entry bundle.
	BundleData []byte
	// LeafHash is the entry's Merkle leaf hash.
	LeafHash []byte
}

SequencedEntry represents a log entry which has already been sequenced.

type TileID

type TileID struct {
	Level uint64
	Index uint64
}

TileID represents a tile address in tile-space.

Jump to

Keyboard shortcuts

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