sqlhist

package
v0.0.0-...-0e8a67c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sqlhist implements a temporal sparse merkle tree using SQL. Each epoch has its own sparse tree. By default, each new epoch is equal to the contents of the previous epoch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrefixLen

func PrefixLen(nodes [][]byte) int

PrefixLen returns the index of the last non-zero item in the list

Types

type Map

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

Map stores a temporal sparse merkle tree, backed by an SQL database.

func New

func New(ctx context.Context, db *sql.DB, mapID int64, factory transaction.Factory) (*Map, error)

New creates a new map.

func (*Map) Commit

func (m *Map) Commit(ctx context.Context) (epoch int64, returnErr error)

Commit takes all the Queued values since the last Commmit() and writes them. Commit is NOT multi-process safe. It should only be called from the sequencer.

func (*Map) Epoch

func (m *Map) Epoch() int64

Epoch returns the current epoch of the merkle tree.

func (*Map) NeighborsAt

func (m *Map) NeighborsAt(txn transaction.Txn, index []byte, epoch int64) ([][]byte, error)

NeighborsAt returns the list of neighbors from the neighbor leaf to just below the root at epoch.

func (*Map) QueueLeaf

func (m *Map) QueueLeaf(txn transaction.Txn, index, leaf []byte) (int64, error)

QueueLeaf should only be called by the sequencer. If txn is nil, the operation will not run in a transaction. QueueLeaf returns the epoch at which the leaf is queued.

func (*Map) ReadLeafAt

func (m *Map) ReadLeafAt(txn transaction.Txn, index []byte, epoch int64) ([]byte, error)

ReadLeafAt returns the leaf value at epoch. If txn is nil, the operation will not run in a transaction.

func (*Map) ReadRootAt

func (m *Map) ReadRootAt(txn transaction.Txn, epoch int64) ([]byte, error)

ReadRootAt returns the value of the root node in a specific epoch. If txn is nil the operation will not run in a transaction.

Jump to

Keyboard shortcuts

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