tree

package
v0.0.0-...-45a04b4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tree contains functions for manipulating generic tree representations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Zero is the value used to represent 0 in the index bit string.
	Zero = byte('0')
	// One is the data used to represent 1 in the index bit string.
	One = byte('1')
)

Functions

func BitString

func BitString(index []byte) string

BitString converts a byte slice index into a string of Depth '0' or '1' characters.

func InvertBitString

func InvertBitString(bindex string) (index []byte, depth int)

InvertBitString converts BitString outputs back into []byte.

func Neighbor

func Neighbor(b uint8) uint8

Neighbor converts Zero into One and visa versa.

func NeighborIndex

func NeighborIndex(index []byte, depth int) []byte

NeighborIndex flips the bit at depth. Does not modify index.

func NeighborString

func NeighborString(bindex string) string

NeighborString inverts the last Zero into a One and visa versa. Note that the root node does not have a Neighbor.

func Neighbors

func Neighbors(bindex string) []string

Neighbors returns a list of all Neighbor indexes from the leaf level up to the root-1.

func Path

func Path(bindex string) []string

Path returns all the intermediate node indexes between a leaf node and the root, ending with the root.

Types

type Sparse

type Sparse interface {
	// QueueLeaf queues a leaf to be written on the next Commit().
	QueueLeaf(txn transaction.Txn, index, leaf []byte) 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.
	Commit(txn transaction.Txn) error
	// ReadRootAt returns the root value at epoch.
	ReadRootAt(txn transaction.Txn, epoch int64) ([]byte, error)
	// ReadLeafAt returns the leaf value at epoch.
	ReadLeafAt(txn transaction.Txn, index []byte, epoch int64) ([]byte, error)
	// Neighbors returns the list of neighbors from the neighbor leaf to just below the root at epoch.
	NeighborsAt(txn transaction.Txn, index []byte, epoch int64) ([][]byte, error)
	// Epoch returns the current epoch of the merkle tree.
	Epoch(txn transaction.Txn) (int64, error)
}

Sparse is a temporal sparse merkle tree.

Directories

Path Synopsis
verifier
Package verifier allows client to verify a tree proof.
Package verifier allows client to verify a tree proof.

Jump to

Keyboard shortcuts

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