Documentation ¶
Index ¶
- func LeafIndex(value uint64) *leafIndex
- func MemoryDb() (res *blockDb)
- func NodeIndex(value uint64) (res *nodeIndex)
- type BlockData
- type Hash
- type Hasher
- type IBlockIndex
- type IShardsMergedMiningTree
- type IStore
- type MmrProof
- type ShardsMergedMiningTree
- func (mmTree *ShardsMergedMiningTree) Append(weight *big.Int, hash []byte) (root Hash, err error)
- func (mmTree *ShardsMergedMiningTree) Copy(db IStore) (IShardsMergedMiningTree, error)
- func (mmTree *ShardsMergedMiningTree) GetProofs(length uint64, indexes ...uint64) (result *MmrProof, err error)
- func (mmTree *ShardsMergedMiningTree) GetRoot(length uint64) (root Hash)
- func (mmTree *ShardsMergedMiningTree) Index() int
- func (mmTree *ShardsMergedMiningTree) MmrFromProofs(db IStore, proof MmrProof) (*ShardsMergedMiningTree, error)
- func (mmTree *ShardsMergedMiningTree) Proof(index uint64, length uint64) (result *ShardsMergedMiningTree, err error)
- func (mmTree *ShardsMergedMiningTree) Proofs(length uint64, indexes ...uint64) (result *ShardsMergedMiningTree, err error)
- func (mmTree *ShardsMergedMiningTree) Root() (root Hash, err error)
- func (mmTree *ShardsMergedMiningTree) Set(index uint64, weight *big.Int, hash []byte) (Hash, error)
- func (mmTree *ShardsMergedMiningTree) ValidateProof(index, length uint64, fullMmr *ShardsMergedMiningTree) (ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IBlockIndex ¶
type IBlockIndex interface { // GetLeftBranch returns left hand branch from current GetLeftBranch() IBlockIndex // GetTop returns ... GetTop() IBlockIndex // RightUp returns upper block navigating by right mountain side // If current block is left side - return nli RightUp() IBlockIndex // IsRight checks if current block is right side sibling IsRight() bool // GetSibling returns sibling // If current brunch is left - return right sibling // If current brunch is right - return left sibling GetSibling() IBlockIndex // GetHeight returns height of this block GetHeight() uint64 // Index returns index of the block // if it's a leaf - returns leaf index // if it's a node - returns node index Index() uint64 // Value returns Block data Value(mmr *ShardsMergedMiningTree) (*BlockData, bool) // SetValue Set block value SetValue(mmr *ShardsMergedMiningTree, data *BlockData) error }
IBlockIndex
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 IShardsMergedMiningTree ¶
type IShardsMergedMiningTree interface { Index() int Root() (root Hash, err error) Set(index uint64, weight *big.Int, hash []byte) (root Hash, err error) Append(weight *big.Int, hash []byte) (root Hash, err error) Copy(db IStore) (IShardsMergedMiningTree, error) }
IShardsMergedMiningTree ...
type IStore ¶
type ShardsMergedMiningTree ¶
func MergedMiningTree ¶
func MergedMiningTree(db IStore, genesis []byte) *ShardsMergedMiningTree
func (*ShardsMergedMiningTree) Copy ¶
func (mmTree *ShardsMergedMiningTree) Copy(db IStore) (IShardsMergedMiningTree, error)
func (*ShardsMergedMiningTree) GetProofs ¶
func (mmTree *ShardsMergedMiningTree) GetProofs(length uint64, indexes ...uint64) (result *MmrProof, err error)
func (*ShardsMergedMiningTree) GetRoot ¶
func (mmTree *ShardsMergedMiningTree) GetRoot(length uint64) (root Hash)
GetRoot returns MMR Root hash Algorithm:
- Take peaks
- Aggregate starting from end to start
func (*ShardsMergedMiningTree) Index ¶
func (mmTree *ShardsMergedMiningTree) Index() int
func (*ShardsMergedMiningTree) MmrFromProofs ¶
func (mmTree *ShardsMergedMiningTree) MmrFromProofs(db IStore, proof MmrProof) (*ShardsMergedMiningTree, error)
func (*ShardsMergedMiningTree) Proof ¶
func (mmTree *ShardsMergedMiningTree) Proof(index uint64, length uint64) (result *ShardsMergedMiningTree, err error)
Proof build an MMR Proof by MMR length and index Algorithm:
- Get current block.
- If left - go to Right. Take it
- Go up. If block exists - take it
- Go to Step 2
func (*ShardsMergedMiningTree) Proofs ¶
func (mmTree *ShardsMergedMiningTree) Proofs(length uint64, indexes ...uint64) (result *ShardsMergedMiningTree, err error)
Proofs build an MMR Proof by MMR length and indexes
func (*ShardsMergedMiningTree) Root ¶
func (mmTree *ShardsMergedMiningTree) Root() (root Hash, err error)
func (*ShardsMergedMiningTree) Set ¶
Set appends ShardsMergedMiningTree with the block data by index
func (*ShardsMergedMiningTree) ValidateProof ¶
func (mmTree *ShardsMergedMiningTree) ValidateProof(index, length uint64, fullMmr *ShardsMergedMiningTree) (ok bool)
ValidateProof validates MMR proof
Click to show internal directories.
Click to hide internal directories.