chainindex

package
v0.0.0-...-b9de96a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 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 BlockIndex

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

BlockIndex is an chainindex from hash to BlockRow.

func InitBlocksIndex

func InitBlocksIndex(genesisBlock primitives.Block) (*BlockIndex, error)

InitBlocksIndex creates a new block chainindex.

func InitBlocksIndexWithCustomBlock

func InitBlocksIndexWithCustomBlock(block *BlockRow) (*BlockIndex, error)

InitBlocksIndex creates a new block chainindex.

func (*BlockIndex) Add

func (i *BlockIndex) Add(block *primitives.Block) (*BlockRow, error)

Add adds a row to the block chainindex.

func (*BlockIndex) Get

func (i *BlockIndex) Get(hash chainhash.Hash) (*BlockRow, bool)

Get gets a block from the block index.

func (*BlockIndex) Have

func (i *BlockIndex) Have(hash chainhash.Hash) bool

Have checks if the block chainindex contains a certain hash.

func (*BlockIndex) LoadBlockNode

func (i *BlockIndex) LoadBlockNode(row *primitives.BlockNodeDisk) (*BlockRow, error)

LoadBlockNode loads a block node and connects it to the parent block.

type BlockRow

type BlockRow struct {
	Height uint64
	Slot   uint64
	Hash   chainhash.Hash
	Parent *BlockRow
	// contains filtered or unexported fields
}

BlockRow represents a single row in the block chainindex.

func (*BlockRow) AddChild

func (br *BlockRow) AddChild(child *BlockRow)

AddChild adds a child to the block row.

func (*BlockRow) Children

func (br *BlockRow) Children() []*BlockRow

Children gets the children of the block row.

func (*BlockRow) GetAncestorAtHeight

func (br *BlockRow) GetAncestorAtHeight(height uint64) *BlockRow

GetAncestorAtHeight gets the block row ancestor at a certain height.

func (*BlockRow) GetAncestorAtSlot

func (br *BlockRow) GetAncestorAtSlot(slot uint64) *BlockRow

GetAncestorAtSlot gets the block row ancestor at a certain slot.

func (*BlockRow) ToBlockNodeDisk

func (br *BlockRow) ToBlockNodeDisk() *primitives.BlockNodeDisk

ToBlockNodeDisk converts an in-memory representation of a block row to a serializable version.

Jump to

Keyboard shortcuts

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