Documentation ¶
Index ¶
- func CalcVoteSeq(blockHeight uint64) uint64
- type CoinbaseReward
- type ConsensusNode
- type ConsensusResult
- func (c *ConsensusResult) ApplyBlock(block *types.Block) error
- func (c *ConsensusResult) ApplyTransaction(tx *types.Tx) error
- func (c *ConsensusResult) AttachCoinbaseReward(block *types.Block) error
- func (c *ConsensusResult) ConsensusNodes() (map[string]*ConsensusNode, error)
- func (c *ConsensusResult) DetachBlock(block *types.Block) error
- func (c *ConsensusResult) DetachCoinbaseReward(block *types.Block) error
- func (c *ConsensusResult) Fork() *ConsensusResult
- func (c *ConsensusResult) GetCoinbaseRewards(blockHeight uint64) ([]CoinbaseReward, error)
- func (c *ConsensusResult) IsFinalize() bool
- type SortByAmount
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcVoteSeq ¶
CalcVoteSeq calculate the vote sequence 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 CoinbaseReward ¶ added in v0.3.0
CoinbaseReward contains receiver and reward
func CalCoinbaseReward ¶ added in v0.3.0
func CalCoinbaseReward(block *types.Block) (*CoinbaseReward, error)
CalCoinbaseReward calculate the coinbase reward for block
type ConsensusNode ¶
ConsensusNode represents a consensus node
type ConsensusResult ¶ added in v0.3.0
type ConsensusResult struct { Seq uint64 NumOfVote map[string]uint64 CoinbaseReward map[string]uint64 BlockHash bc.Hash BlockHeight uint64 }
ConsensusResult 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 CoinbaseReward indicates the coinbase receiver and reward
func (*ConsensusResult) ApplyBlock ¶ added in v0.3.0
func (c *ConsensusResult) ApplyBlock(block *types.Block) error
ApplyBlock calculate the consensus result for new block
func (*ConsensusResult) ApplyTransaction ¶ added in v0.3.0
func (c *ConsensusResult) ApplyTransaction(tx *types.Tx) error
ApplyTransaction calculate the consensus result for transaction
func (*ConsensusResult) AttachCoinbaseReward ¶ added in v0.3.0
func (c *ConsensusResult) AttachCoinbaseReward(block *types.Block) error
AttachCoinbaseReward attach coinbase reward
func (*ConsensusResult) ConsensusNodes ¶ added in v0.3.0
func (c *ConsensusResult) ConsensusNodes() (map[string]*ConsensusNode, error)
ConsensusNodes returns all consensus nodes
func (*ConsensusResult) DetachBlock ¶ added in v0.3.0
func (c *ConsensusResult) DetachBlock(block *types.Block) error
DetachBlock calculate the consensus result for detach block
func (*ConsensusResult) DetachCoinbaseReward ¶ added in v0.3.0
func (c *ConsensusResult) DetachCoinbaseReward(block *types.Block) error
DetachCoinbaseReward detach coinbase reward
func (*ConsensusResult) Fork ¶ added in v0.3.0
func (c *ConsensusResult) Fork() *ConsensusResult
Fork copy the ConsensusResult struct
func (*ConsensusResult) GetCoinbaseRewards ¶ added in v0.3.0
func (c *ConsensusResult) GetCoinbaseRewards(blockHeight uint64) ([]CoinbaseReward, error)
GetCoinbaseRewards convert into CoinbaseReward array and sort it by amount
func (*ConsensusResult) IsFinalize ¶ added in v0.3.0
func (c *ConsensusResult) IsFinalize() bool
IsFinalize check if the result is end of consensus round
type SortByAmount ¶ added in v0.3.0
type SortByAmount []CoinbaseReward
SortByAmount implements sort.Interface for CoinbaseReward slices
func (SortByAmount) Len ¶ added in v0.3.0
func (a SortByAmount) Len() int
func (SortByAmount) Less ¶ added in v0.3.0
func (a SortByAmount) Less(i, j int) bool
func (SortByAmount) Swap ¶ added in v0.3.0
func (a SortByAmount) Swap(i, j int)
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