merkel

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content interface {
	// This function returns SHA256 hash of the object.
	CalcHash() ([]byte, error)
	// Whether ths content equal another content.
	Equals(content Content) (bool, error)
}

This defines the object that will get stored in Merkle tree.

type MerkleTree

type MerkleTree struct {
	Root  *Node
	Leafs []*Node
}

The Merkle tree object. It contains pointer to contents that are stored in it, as well as the tree root.

func (*MerkleTree) Init

func (tree *MerkleTree) Init(contents []Content) error

This function inits a Merkle tree, it takes in a list of Content, and init the entire tree.

type Node

type Node struct {
	Hash  []byte
	Left  *Node
	Right *Node
	Value Content
}

This represents the Node that are stored in Merkle tree. A node becomes a leaf when Value is not nil.

Jump to

Keyboard shortcuts

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