Documentation ¶
Index ¶
- func NewBlockHeader(bits uint32, pow pow.IPow) model.BlockHeader
- type GhostDAG
- func (gm *GhostDAG) ChooseSelectedParent(stagingArea *cmodel.StagingArea, blockHashes ...*hash.Hash) (*hash.Hash, error)
- func (gm *GhostDAG) FindSelectedParent(stagingArea *cmodel.StagingArea, parentHashes []*hash.Hash) (*hash.Hash, error)
- func (gm *GhostDAG) GHOSTDAG(stagingArea *cmodel.StagingArea, blockHash *hash.Hash) error
- func (gm *GhostDAG) GenesisHash() *hash.Hash
- func (gm *GhostDAG) GetSortedMergeSet(stagingArea *cmodel.StagingArea, current *hash.Hash) ([]*hash.Hash, error)
- func (gm *GhostDAG) Less(blockHashA *hash.Hash, ghostdagDataA *model.BlockGHOSTDAGData, ...) bool
- func (gm *GhostDAG) SetGenesisHash(h *hash.Hash)
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 (*GhostDAG) FindSelectedParent ¶
func (*GhostDAG) GHOSTDAG ¶
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
- 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 (*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