merkle

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeTwoHash

func MergeTwoHash(l *hash.Hash, r *hash.Hash) *hash.Hash

MergeTwoHash computes the hash of the concatenate of two hash.

Types

type Merkle

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

Merkle is a merkle tree implementation (https://en.wikipedia.org/wiki/Merkle_tree).

func NewMerkle

func NewMerkle(items []*hash.Hash) *Merkle

NewMerkle generate a merkle tree according to some hashable values like transactions or blocks.

func (*Merkle) GetRoot

func (merkle *Merkle) GetRoot() *hash.Hash

GetRoot returns the root of merkle tree.

type Trie

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

Trie is a patricia trie.

func NewPatricia

func NewPatricia() *Trie

NewPatricia is patricia construction.

func (*Trie) Get

func (trie *Trie) Get(key []byte) ([]byte, error)

Get returns the value according to the key.

func (*Trie) Insert

func (trie *Trie) Insert(key []byte, value []byte) (inserted bool)

Insert serializes key into binary and computes its hash, then stores the (hash(key), value) into the trie.

Jump to

Keyboard shortcuts

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