merkletree

package
v0.0.0-...-98bfee9 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodePrefix       = 'T'
	AllocCounterKey  = "AC"
	NodeKeyDelimiter = 'N'
	SnapshotNrBytes  = 8
	IndexLengthBytes = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LookupTracingNode

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

func (*LookupTracingNode) Child

func (n *LookupTracingNode) Child(rightChild bool) (coname.MerkleNode, error)

func (*LookupTracingNode) ChildHash

func (n *LookupTracingNode) ChildHash(rightChild bool) []byte

func (*LookupTracingNode) Depth

func (n *LookupTracingNode) Depth() int

func (*LookupTracingNode) Index

func (n *LookupTracingNode) Index() []byte

func (*LookupTracingNode) IsEmpty

func (n *LookupTracingNode) IsEmpty() bool

func (*LookupTracingNode) IsLeaf

func (n *LookupTracingNode) IsLeaf() bool

func (*LookupTracingNode) Value

func (n *LookupTracingNode) Value() []byte

type MerkleTree

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

func AccessMerkleTree

func AccessMerkleTree(db kv.DB, prefix []byte, treeNonce []byte) (*MerkleTree, error)

AccessMerkleTree opens the Merkle tree stored in the DB. There should never be two different MerkleTree objects accessing the same tree.

func (*MerkleTree) GetSnapshot

func (tree *MerkleTree) GetSnapshot(nr uint64) *Snapshot

GetSnapshot loads the snapshot with a particular ID. Use 0 for a new empty snapshot. GetSnapshot always returns a snapshot handle, regardless of whether the snapshot actually exists. It is an error to call GetSnapshot(nr) if snapshot nr does not exist (a dangling snapshot handle will be returned).

type NewSnapshot

type NewSnapshot struct {
	Snapshot
	// contains filtered or unexported fields
}

NewSnapshot represents a snapshot that is being built up in memory.

func (*NewSnapshot) Flush

func (snapshot *NewSnapshot) Flush(wb kv.Batch) (flushed *Snapshot)

Flush returns a newly usable Snapshot

func (*NewSnapshot) Lookup

func (snapshot *NewSnapshot) Lookup(indexBytes []byte) (value []byte, trace *proto.TreeProof, err error)

func (*NewSnapshot) Set

func (snapshot *NewSnapshot) Set(indexBytes []byte, value []byte) (err error)

Set updates the leaf value at the index (or inserts it if it did not exist). In-memory: doesn't actually touch the disk yet.

type Snapshot

type Snapshot struct {
	Nr uint64
	// contains filtered or unexported fields
}

Snapshot represents a particular (immutable) state of the tree. Changes are made by calling BeginModification(), updating the returned NewSnapshot, and then getting an updated Snapshot out from Flush().

func (*Snapshot) BeginModification

func (snapshot *Snapshot) BeginModification() (*NewSnapshot, error)

BeginModification creates a new snapshot to be built up in memory (doesn't actually touch the disk yet)

func (*Snapshot) GetRootHash

func (snapshot *Snapshot) GetRootHash() ([]byte, error)

GetRootHash gets the summary hash for the entire state of the tree.

func (*Snapshot) Lookup

func (snapshot *Snapshot) Lookup(indexBytes []byte) (value []byte, trace *proto.TreeProof, err error)

Jump to

Keyboard shortcuts

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