ghostdag

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBlockHeader

func NewBlockHeader(bits uint32, pow pow.IPow) model.BlockHeader

Types

type GhostDAG

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

GhostDAG resolves and manages GHOSTDAG block data

func New

func New(
	databaseContext model.DBReader,
	dagTopologyManager model.DAGTopologyManager,
	ghostdagDataStore model.GHOSTDAGDataStore,
	headerStore model.BlockHeaderStore,
	k model.KType,
	genesisHash *hash.Hash) *GhostDAG

New instantiates a new GhostDAG

func (*GhostDAG) ChooseSelectedParent

func (gm *GhostDAG) ChooseSelectedParent(stagingArea *cmodel.StagingArea, blockHashes ...*hash.Hash) (*hash.Hash, error)

func (*GhostDAG) FindSelectedParent

func (gm *GhostDAG) FindSelectedParent(stagingArea *cmodel.StagingArea, parentHashes []*hash.Hash) (*hash.Hash, error)

func (*GhostDAG) GHOSTDAG

func (gm *GhostDAG) GHOSTDAG(stagingArea *cmodel.StagingArea, blockHash *hash.Hash) error

GHOSTDAG runs the GHOSTDAG protocol and calculates the block BlockGHOSTDAGData by the given parents. The function calculates MergeSetBlues by iterating over the blocks in the anticone of the new block selected parent (which is the parent with the highest blue score) and adds any block to newNode.blues if by adding it to MergeSetBlues these conditions will not be violated:

1) |anticone-of-candidate-block ∩ blue-set-of-newBlock| ≤ K

  1. For every blue block in blue-set-of-newBlock: |(anticone-of-blue-block ∩ blue-set-newBlock) ∪ {candidate-block}| ≤ K. We validate this condition by maintaining a map BluesAnticoneSizes for each block which holds all the blue anticone sizes that were affected by the new added blue blocks. So to find out what is |anticone-of-blue ∩ blue-set-of-newBlock| we just iterate in the selected parent chain of the new block until we find an existing entry in BluesAnticoneSizes.

For further details see the article https://eprint.iacr.org/2018/104.pdf

func (*GhostDAG) GenesisHash

func (gm *GhostDAG) GenesisHash() *hash.Hash

func (*GhostDAG) GetSortedMergeSet

func (gm *GhostDAG) GetSortedMergeSet(stagingArea *cmodel.StagingArea,
	current *hash.Hash) ([]*hash.Hash, error)

GetSortedMergeSet return the merge set sorted in a toplogical order.

func (*GhostDAG) Less

func (gm *GhostDAG) Less(blockHashA *hash.Hash, ghostdagDataA *model.BlockGHOSTDAGData,
	blockHashB *hash.Hash, ghostdagDataB *model.BlockGHOSTDAGData) bool

func (*GhostDAG) SetGenesisHash

func (gm *GhostDAG) SetGenesisHash(h *hash.Hash)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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