sqlhist

package
v0.0.0-...-02c3ccb Latest Latest
Warning

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

Go to latest
Published: May 22, 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, mapID int64, factory transaction.Factory) (m *Map, returnErr error)

New creates a new map.

func (*Map) Commit

func (m *Map) Commit(txn transaction.Txn) 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(txn transaction.Txn) (int64, error)

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) error

QueueLeaf should only be called by the sequencer.

func (*Map) ReadLeafAt

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

ReadLeafAt returns the leaf value at epoch.

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.

Jump to

Keyboard shortcuts

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