state

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: AGPL-3.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcVoteSeq

func CalcVoteSeq(blockHeight uint64) uint64

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

type CoinbaseReward struct {
	Amount         uint64
	ControlProgram []byte
}

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

type ConsensusNode struct {
	XPub    chainkd.XPub
	VoteNum uint64
	Order   uint64
}

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

type UtxoViewpoint struct {
	Entries map[bc.Hash]*storage.UtxoEntry
}

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 (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx, statusFail bool) error

func (*UtxoViewpoint) CanSpend

func (view *UtxoViewpoint) CanSpend(hash *bc.Hash) bool

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

func (*UtxoViewpoint) HasUtxo

func (view *UtxoViewpoint) HasUtxo(hash *bc.Hash) bool

Jump to

Keyboard shortcuts

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