dag

package
v0.0.0-...-acc7c72 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBeforeFence

func IsBeforeFence(hash common.Hash, members *[]common.Hash, fence int) bool

func RemoveIfExist

func RemoveIfExist(elem common.Hash, slice *[]common.Hash) bool

remove element from the slice if the element exists, remove it and return true if not, return false

Types

type DAGBlock

type DAGBlock struct {
	BlockHash   common.Hash
	Number      uint64
	ParentHash  common.Hash
	ReferHashes []common.Hash
	Difficulty  *big.Int
	//-----------------------------
	SubtreeDifficulty *big.Int
	ChildHashes       []common.Hash
	// contains filtered or unexported fields
}

func (*DAGBlock) Clone

func (dagBlock *DAGBlock) Clone() *DAGBlock

clone a DAGBlock object

type DAGCore

type DAGCore struct {
	ID int
	// contains filtered or unexported fields
}

func NewDAGCore

func NewDAGCore(id int) *DAGCore

func (*DAGCore) CanBlockInsert

func (dag *DAGCore) CanBlockInsert(dagBlock *DAGBlock) (canOrNot bool)

judge whether the block can be inserted into the DAG

func (*DAGCore) CheckConsensus

func (dag *DAGCore) CheckConsensus(otherDag *DAGCore) error

check the consensus between two dags

func (*DAGCore) CurrentBlock

func (dag *DAGCore) CurrentBlock() (hash common.Hash, err error)

func (*DAGCore) GetBlockByHash

func (dag *DAGCore) GetBlockByHash(hash common.Hash) *DAGBlock

func (*DAGCore) GetEpochByHash

func (dag *DAGCore) GetEpochByHash(epochHash common.Hash) (epoch *EpochMeta, err error)

func (*DAGCore) GetEpochByNumber

func (dag *DAGCore) GetEpochByNumber(epochNumber uint64) (epoch *EpochMeta, err error)

func (*DAGCore) GetFutureReferenceBlock

func (dag *DAGCore) GetFutureReferenceBlock() (hashes []common.Hash, err error)

func (*DAGCore) GetTipEnds

func (dag *DAGCore) GetTipEnds() (tipEnds []*DAGBlock, err error)

func (*DAGCore) InitDAG

func (dag *DAGCore) InitDAG(blocks []*types.Block) error

func (*DAGCore) InsertBlock

func (dag *DAGCore) InsertBlock(block *types.Block) bool

block insert into dag

func (*DAGCore) InsertBlocks

func (dag *DAGCore) InsertBlocks(epochBlocks []*types.Block) error

func (*DAGCore) InsertDAGBlock

func (dag *DAGCore) InsertDAGBlock(dagBlock *DAGBlock) bool

block insert into dag

func (*DAGCore) InsertDagBlocks

func (dag *DAGCore) InsertDagBlocks(epochDagBlocks []*DAGBlock) error

func (*DAGCore) IsBlockInDAG

func (dag *DAGCore) IsBlockInDAG(hash common.Hash) (IsOrNot bool)

func (*DAGCore) PrintDagBlock

func (dag *DAGCore) PrintDagBlock(dagBlock *DAGBlock)

func (*DAGCore) PrintDagBlocks

func (dag *DAGCore) PrintDagBlocks()

func (*DAGCore) PrintEpoch

func (dag *DAGCore) PrintEpoch(epoch *EpochMeta)

func (*DAGCore) PrintEpoches

func (dag *DAGCore) PrintEpoches()

func (*DAGCore) PrintTipEnds

func (dag *DAGCore) PrintTipEnds()

func (*DAGCore) PrintTips

func (dag *DAGCore) PrintTips()

type EpochMeta

type EpochMeta struct {
	EpochNumber       uint64
	BlockHash         common.Hash
	MemberBlockHashes []common.Hash
}

type HashSlice

type HashSlice []common.Hash

func (HashSlice) Len

func (s HashSlice) Len() int

func (HashSlice) Less

func (s HashSlice) Less(i, j int) bool

func (HashSlice) Swap

func (s HashSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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