history

package
v0.3.0-docs.0...-f96dd80 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package history implements the history tree (a merkel tree, append only structure) life cycle, its operations, different visitors to navigate the tree, as well as the functionality of request and verify membership and incremental proofs.

Index

Constants

This section is empty.

Variables

View Source
var (
	AddTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subSystem,
			Name:      "add_total",
			Help:      "Number of the events added to the history tree.",
		},
	)
	MembershipTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subSystem,
			Name:      "membership_total",
			Help:      "Number of membership queries",
		},
	)
	ConsistencyTotal = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: subSystem,
			Name:      "consistency_total",
			Help:      "Number of consistency queries",
		},
	)
)

Functions

This section is empty.

Types

type AuditPath

type AuditPath map[[keySize]byte]hashing.Digest

func ParseAuditPath

func ParseAuditPath(serialized map[string]hashing.Digest) AuditPath

func (AuditPath) Get

func (p AuditPath) Get(pos []byte) ([]byte, bool)

func (AuditPath) Serialize

func (p AuditPath) Serialize() map[string]hashing.Digest

type HistoryTree

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

func NewHistoryTree

func NewHistoryTree(hasherF func() hashing.Hasher, store storage.Store, cacheSize uint16) *HistoryTree

func (*HistoryTree) Add

func (t *HistoryTree) Add(eventDigest hashing.Digest, version uint64) (hashing.Digest, []*storage.Mutation, error)

Add function adds an event digest into the history tree. It builds an insert visitor, calculates the expected root hash, and returns it along with the storage mutations to be done at balloon level.

func (*HistoryTree) AddBulk

func (t *HistoryTree) AddBulk(eventDigests []hashing.Digest, initialVersion uint64) ([]hashing.Digest, []*storage.Mutation, error)

AddBulk function adds a bulk of event digests (one after another) into the history tree. It builds an insert visitor, calculates the expected bulk of root hashes, and returns them along with the storage mutations to be done at balloon level.

func (*HistoryTree) Close

func (t *HistoryTree) Close()

Close function resets history tree's write and read caches, and hasher.

func (*HistoryTree) ProveConsistency

func (t *HistoryTree) ProveConsistency(start, end uint64) (*IncrementalProof, error)

ProveConsistency function builds the incremental proof between the given event versions. It builds an audit-path visitor to build the proof.

func (*HistoryTree) ProveMembership

func (t *HistoryTree) ProveMembership(index, version uint64) (*MembershipProof, error)

ProveMembership function builds the membership proof of the given index against the given version. It builds an audit-path visitor to build the proof.

type IncrementalProof

type IncrementalProof struct {
	AuditPath                AuditPath
	StartVersion, EndVersion uint64
	// contains filtered or unexported fields
}

func NewIncrementalProof

func NewIncrementalProof(start, end uint64, auditPath AuditPath, hasher hashing.Hasher) *IncrementalProof

func (IncrementalProof) Verify

func (p IncrementalProof) Verify(startDigest, endDigest hashing.Digest) (correct bool)

type MembershipProof

type MembershipProof struct {
	AuditPath      AuditPath
	Index, Version uint64
	// contains filtered or unexported fields
}

func NewMembershipProof

func NewMembershipProof(index, version uint64, auditPath AuditPath, hasher hashing.Hasher) *MembershipProof

func (MembershipProof) Verify

func (p MembershipProof) Verify(eventDigest []byte, expectedRootHash hashing.Digest) (correct bool)

Verify verifies a membership proof

Jump to

Keyboard shortcuts

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