mmr

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: ISC Imports: 11 Imported by: 0

Documentation

Overview

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadgerDB

func BadgerDB(path string) (*badgerDB, error)

func LeafIndex

func LeafIndex(value uint64) (res *leafIndex)

func MemoryDb

func MemoryDb() (res *blockDb)

func Mmr

func Mmr(hasher Hasher, db IStore) *mmr

func NodeIndex

func NodeIndex(value uint64) (res *nodeIndex)

Types

type BlockData

type BlockData struct {
	Weight *big.Int
	Hash   Hash
}

func (*BlockData) Digest

func (d *BlockData) Digest(hasher Hasher) (result Hash)

Calculate Block Digest

type Hash

type Hash [32]byte

func (*Hash) String

func (h *Hash) String() string

type Hasher

type Hasher func() hash.Hash

type IBlockIndex

type IBlockIndex interface {
	//Returns left hand branch from current
	GetLeftBranch() IBlockIndex
	//Get Peak Block from current
	GetTop() IBlockIndex

	//Get upper block navigating by right mountain side
	//If current block is left side - return nli
	RightUp() IBlockIndex

	//Check if current block is right side sibling
	IsRight() bool

	//Returns sibling
	// If current brunch is left - return right sibling
	// If current brunch is right - return left sibling
	GetSibling() IBlockIndex

	//Get height of this block
	GetHeight() uint64

	//Get Index of the block
	// if it's a leaf - returns leaf index
	// if it's a node - returns node index
	Index() uint64

	//Get Block data
	Value(mmr *mmr) (*BlockData, bool)

	//Set block value
	SetValue(mmr *mmr, data *BlockData)
}

MMR Blocks navigation abstraction Might be two types of MMR block

  • Leafs. It's a bottom layer, representing block data
  • Nodes. It's a Mountain nodes data, representing aggregation of bottom layers

type IMountainRange

type IMountainRange interface {
	Set(index uint64, weight *big.Int, hash []byte) (root Hash)
	Append(weight *big.Int, hash []byte) (root Hash)
	Index() int
	Root() (root Hash)
	Copy(db IStore) IMountainRange
}

type IStore

type IStore interface {
	GetNode(index uint64) (res *BlockData, ok bool)
	SetNode(index uint64, data *BlockData)
	GetBlock(index uint64) (res *BlockData, ok bool)
	SetBlock(index uint64, data *BlockData)
	Nodes() (res []uint64)
	Blocks() (res []uint64)
	Debug()
}

type MmrProof

type MmrProof struct {
	Nodes map[uint64]*BlockData
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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