logdb

package
v0.0.0-...-8138375 Latest Latest
Warning

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

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

Documentation

Overview

Package logdb contains read/write access to the locally cloned data.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDataFound = errors.New("no data found")

ErrNoDataFound is returned when the DB appears valid but has no data in it.

Functions

This section is empty.

Types

type Database

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

Database provides read/write access to the mirrored log.

func NewDatabase

func NewDatabase(connString string) (*Database, error)

NewDatabase creates a Database using the given database connection string. This has been tested with sqlite and MariaDB.

func NewDatabaseDirect

func NewDatabaseDirect(db *sql.DB) (*Database, error)

NewDatabaseDirect creates a Database using the given database connection.

func (*Database) GetLatestCheckpoint

func (d *Database) GetLatestCheckpoint(ctx context.Context) (size uint64, checkpoint []byte, compactRange [][]byte, err error)

GetLatestCheckpoint gets the details of the latest checkpoint.

func (*Database) Head

func (d *Database) Head() (int64, error)

Head returns the largest leaf index written.

func (*Database) StreamLeaves

func (d *Database) StreamLeaves(ctx context.Context, start, end uint64, out chan<- StreamResult)

StreamLeaves streams leaves in order starting at the given index, putting the leaf preimage values on the `out` channel. This takes ownership of the out channel and closes it when no more data will be returned.

func (*Database) WriteCheckpoint

func (d *Database) WriteCheckpoint(ctx context.Context, size uint64, checkpoint []byte, compactRange [][]byte) error

WriteCheckpoint writes the checkpoint for the given tree size. This should have been verified before writing.

func (*Database) WriteLeaves

func (d *Database) WriteLeaves(ctx context.Context, start uint64, leaves [][]byte) error

WriteLeaves writes the contiguous chunk of leaves, starting at the stated index. This is an atomic operation, and will fail if any leaf cannot be inserted.

type StreamResult

type StreamResult struct {
	Leaf []byte
	Err  error
}

StreamResult is the return type for StreamLeaves. It allows the leaves to be returned in the same channel as any errors. Only one of Leaf or Err will be populated in any StreamResult.

Jump to

Keyboard shortcuts

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