mmr

package
v0.4.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ValueSize = 40

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockNode

type BlockNode struct {
	Leaf

	ID         uint64         // ID of node in the MMR Tree, if ID < math.MaxInt32, ID == block height in main chain.
	PrevNodeID uint64         // PrevNodeID hash of previous block
	ActualRoot chainhash.Hash // ActualRoot is a root of the MMR Tree when this node was latest
}

func (*BlockNode) Clone

func (n *BlockNode) Clone() *BlockNode

func (*BlockNode) MarshalJSON

func (n *BlockNode) MarshalJSON() ([]byte, error)

type BlocksMMRTree

type BlocksMMRTree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTree

func NewTree() *BlocksMMRTree

func (*BlocksMMRTree) AddBlock

func (t *BlocksMMRTree) AddBlock(hash chainhash.Hash, difficulty uint64)

AddBlock adds block as latest leaf, increases height and rebuild tree.

func (*BlocksMMRTree) Block

func (t *BlocksMMRTree) Block(height int32) *BlockNode

func (*BlocksMMRTree) Current

func (t *BlocksMMRTree) Current() *BlockNode

func (*BlocksMMRTree) CurrentRoot

func (t *BlocksMMRTree) CurrentRoot() chainhash.Hash

func (*BlocksMMRTree) Fork added in v0.4.2

func (t *BlocksMMRTree) Fork() *BlocksMMRTree

func (*BlocksMMRTree) LookupNodeByRoot

func (t *BlocksMMRTree) LookupNodeByRoot(hash chainhash.Hash) (*BlockNode, bool)

func (*BlocksMMRTree) MarshalJSON added in v0.4.2

func (t *BlocksMMRTree) MarshalJSON() ([]byte, error)

func (*BlocksMMRTree) Parent

func (t *BlocksMMRTree) Parent(height int32) *BlockNode

func (*BlocksMMRTree) ResetRootTo

func (t *BlocksMMRTree) ResetRootTo(hash chainhash.Hash, height int32)

ResetRootTo sets provided block with <hash, height> as latest and drops all blocks after this.

func (*BlocksMMRTree) RmBlock

func (t *BlocksMMRTree) RmBlock(hash chainhash.Hash, height int32)

RmBlock drops all block from latest to (including) provided block with <hash, height>.

func (*BlocksMMRTree) RootForHeight

func (t *BlocksMMRTree) RootForHeight(height int32) chainhash.Hash

func (*BlocksMMRTree) SetBlock

func (t *BlocksMMRTree) SetBlock(hash chainhash.Hash, difficulty uint64, height int32)

SetBlock sets provided block with <hash, height> as latest. If block height is not latest, then reset tree to height - 1 and add AddBLock.

type Leaf

type Leaf struct {
	Hash   chainhash.Hash
	Weight uint64
	// contains filtered or unexported fields
}

func BuildMerkleTreeStore

func BuildMerkleTreeStore(blocks []Leaf) []*Leaf

func HashMerkleBranches

func HashMerkleBranches(left, right *Leaf) *Leaf

func (*Leaf) Value

func (b *Leaf) Value() Value

type Value

type Value [ValueSize]byte

func (Value) Block

func (v Value) Block() (b Leaf)

Jump to

Keyboard shortcuts

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