Documentation
¶
Index ¶
- func CalcVoteSeq(blockHeight uint64) uint64
- type BlockIndex
- func (bi *BlockIndex) AddNode(node *BlockNode)
- func (bi *BlockIndex) BestNode() *BlockNode
- func (bi *BlockIndex) BlockExist(hash *bc.Hash) bool
- func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode
- func (bi *BlockIndex) InMainchain(hash bc.Hash) bool
- func (bi *BlockIndex) NodeByHeight(height uint64) *BlockNode
- func (bi *BlockIndex) NodesByHeight(height uint64) []*BlockNode
- func (bi *BlockIndex) SetMainChain(node *BlockNode)
- type BlockNode
- type ConsensusNode
- type UtxoViewpoint
- func (view *UtxoViewpoint) ApplyBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
- func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx, statusFail bool) error
- func (view *UtxoViewpoint) CanSpend(hash *bc.Hash) bool
- func (view *UtxoViewpoint) DetachBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
- func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx, statusFail bool) error
- func (view *UtxoViewpoint) HasUtxo(hash *bc.Hash) bool
- type VoteResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcVoteSeq ¶
seq 0 is the genesis block seq 1 is the the block height 1, to block height RoundVoteBlockNums seq 2 is the block height RoundVoteBlockNums + 1 to block height 2 * RoundVoteBlockNums consensus node of the current round is the final result of previous round
Types ¶
type BlockIndex ¶
BlockIndex is the struct for help chain trace block chain as tree
func (*BlockIndex) AddNode ¶
func (bi *BlockIndex) AddNode(node *BlockNode)
AddNode will add node to the index map
func (*BlockIndex) BestNode ¶
func (bi *BlockIndex) BestNode() *BlockNode
func (*BlockIndex) BlockExist ¶
func (bi *BlockIndex) BlockExist(hash *bc.Hash) bool
BlockExist check does the block existed in blockIndex
func (*BlockIndex) GetNode ¶
func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode
GetNode will search node from the index map
func (*BlockIndex) InMainchain ¶
func (bi *BlockIndex) InMainchain(hash bc.Hash) bool
TODO: THIS FUNCTION MIGHT BE DELETED
func (*BlockIndex) NodeByHeight ¶
func (bi *BlockIndex) NodeByHeight(height uint64) *BlockNode
NodeByHeight returns the block node at the specified height.
func (*BlockIndex) NodesByHeight ¶
func (bi *BlockIndex) NodesByHeight(height uint64) []*BlockNode
NodesByHeight return all block nodes at the specified height.
func (*BlockIndex) SetMainChain ¶
func (bi *BlockIndex) SetMainChain(node *BlockNode)
SetMainChain will set the the mainChain array
type BlockNode ¶
type BlockNode struct { Parent *BlockNode // parent is the parent block for this node. Hash bc.Hash // hash of the block. Version uint64 Height uint64 Timestamp uint64 BlockWitness *common.BitMap TransactionsMerkleRoot bc.Hash TransactionStatusHash bc.Hash }
BlockNode represents a block within the block chain and is primarily used to aid in selecting the best chain to be the main chain.
func NewBlockNode ¶
func NewBlockNode(bh *types.BlockHeader, parent *BlockNode) (*BlockNode, error)
func (*BlockNode) BlockHeader ¶
func (node *BlockNode) BlockHeader() *types.BlockHeader
blockHeader convert a node to the header struct
func (*BlockNode) CalcPastMedianTime ¶
type UtxoViewpoint ¶
UtxoViewpoint represents a view into the set of unspent transaction outputs
func NewUtxoViewpoint ¶
func NewUtxoViewpoint() *UtxoViewpoint
NewUtxoViewpoint returns a new empty unspent transaction output view.
func (*UtxoViewpoint) ApplyBlock ¶
func (view *UtxoViewpoint) ApplyBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
func (*UtxoViewpoint) ApplyTransaction ¶
func (*UtxoViewpoint) DetachBlock ¶
func (view *UtxoViewpoint) DetachBlock(block *bc.Block, txStatus *bc.TransactionStatus) error
func (*UtxoViewpoint) DetachTransaction ¶
func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx, statusFail bool) error
type VoteResult ¶
type VoteResult struct { Seq uint64 NumOfVote map[string]uint64 BlockHash bc.Hash BlockHeight uint64 }
VoteResult represents a snapshot of each round of DPOS voting Seq indicates the sequence of current votes, which start from zero NumOfVote indicates the number of votes each consensus node receives, the key of map represent public key Finalized indicates whether this vote is finalized
func (*VoteResult) ApplyBlock ¶
func (v *VoteResult) ApplyBlock(block *types.Block) error
func (*VoteResult) ConsensusNodes ¶
func (v *VoteResult) ConsensusNodes() (map[string]*ConsensusNode, error)
func (*VoteResult) DetachBlock ¶
func (v *VoteResult) DetachBlock(block *types.Block) error
func (*VoteResult) Fork ¶
func (v *VoteResult) Fork() *VoteResult
func (*VoteResult) IsFinalize ¶
func (v *VoteResult) IsFinalize() bool