Versions in this module Expand all Collapse all v1 v1.0.1 Mar 1, 2020 Changes in this version + const BlockCountPerYear + const BlockInterval + const ConsensusSize + const DonationRatio + const EpochInterval + const MaxValidatorSize + const MaxVoteCount + const PercentageDenominator + const RewardRatioDenominator + const SafeSize + const ThawingEpochDuration + var ErrInvalidBlockValidator = errors.New("invalid block validator") + var ErrInvalidTimestamp = errors.New("invalid timestamp") + var ErrMinedFutureBlock = errors.New("mined the future block") + var ErrMismatchSignerAndValidator = errors.New("mismatch block signer and validator") + var ErrNilBlockHeader = errors.New("nil block header returned") + var ErrWaitForPrevBlock = errors.New("wait for last block arrived") + var KeyCandidateDeposit = common.BytesToHash([]byte("candidates-deposit")) + var KeyFrozenAssets = common.BytesToHash([]byte("frozen-assets")) + var KeyPreEpochSnapshotDelegateTrieRoot = common.BytesToHash([]byte("pre-epoch-dtr")) + var KeyRewardRatioNumerator = common.BytesToHash([]byte("reward-ratio-numerator")) + var KeyRewardRatioNumeratorLastEpoch = common.BytesToHash([]byte("reward-ratio-last-epoch")) + var KeySumAllocatedReward = common.BytesToHash([]byte("sum-allocated-reward")) + var KeyTotalVote = common.BytesToHash([]byte("total-vote")) + var KeyValueCommonAddress = common.BigToAddress(big.NewInt(0)) + var KeyVoteDeposit = common.BytesToHash([]byte("vote-deposit")) + var KeyVoteLastEpoch = common.BytesToHash([]byte("vote-last-epoch")) + var PrefixThawingAddr = "thawing_" + var PrefixThawingAssets = []byte("thawing-assets") + func AddFrozenAssets(state stateDB, addr common.Address, diff common.BigInt) + func AddThawingAssets(state stateDB, addr common.Address, epoch int64, diff common.BigInt) + func CalcCandidateTotalVotes(candidateAddr common.Address, state stateDB, delegateTrie *trie.Trie) common.BigInt + func CalculateEpochID(blockTime int64) int64 + func CandidateTxDataValidation(state stateDB, data types.AddCandidateTxData, candidateAddress common.Address) error + func GetAvailableBalance(state stateDB, addr common.Address) common.BigInt + func GetBalance(state stateDB, addr common.Address) common.BigInt + func GetCandidateDeposit(state stateDB, addr common.Address) common.BigInt + func GetFrozenAssets(state stateDB, addr common.Address) common.BigInt + func GetPreEpochSnapshotDelegateTrieRoot(state stateDB, genesis *types.Header) common.Hash + func GetRewardRatioNumerator(state stateDB, addr common.Address) uint64 + func GetRewardRatioNumeratorLastEpoch(state stateDB, addr common.Address) uint64 + func GetThawingAssets(state stateDB, addr common.Address, epoch int64) common.BigInt + func GetVoteDeposit(state stateDB, addr common.Address) common.BigInt + func GetVoteLastEpoch(state stateDB, addr common.Address) common.BigInt + func HasVoted(delegatorAddress common.Address, header *types.Header, diskDB ethdb.Database) bool + func IsCandidate(candidateAddress common.Address, header *types.Header, diskDB ethdb.Database) bool + func NextSlot(now int64) int64 + func PrevSlot(now int64) int64 + func ProcessAddCandidate(state stateDB, ctx *types.DposContext, addr common.Address, ...) error + func ProcessCancelCandidate(state stateDB, ctx *types.DposContext, addr common.Address, time int64) error + func ProcessCancelVote(state stateDB, ctx *types.DposContext, addr common.Address, time int64) error + func ProcessVote(state stateDB, ctx *types.DposContext, addr common.Address, ...) (int, error) + func SetCandidateDeposit(state stateDB, addr common.Address, deposit common.BigInt) + func SetFrozenAssets(state stateDB, addr common.Address, value common.BigInt) + func SetRewardRatioNumerator(state stateDB, addr common.Address, value uint64) + func SetRewardRatioNumeratorLastEpoch(state stateDB, addr common.Address, value uint64) + func SetThawingAssets(state stateDB, addr common.Address, epoch int64, value common.BigInt) + func SetVoteDeposit(state stateDB, addr common.Address, deposit common.BigInt) + func SetVoteLastEpoch(state stateDB, addr common.Address, value common.BigInt) + func SubFrozenAssets(state stateDB, addr common.Address, diff common.BigInt) error + func VoteTxDepositValidation(state stateDB, delegatorAddress common.Address, voteData types.VoteTxData) error + type API struct + func (api *API) GetConfirmedBlockNumber() (*big.Int, error) + type APIHelper struct + func NewAPIHelper(bc BlockChain) *APIHelper + func (ah *APIHelper) CalcValidatorDistributionInRange(validator common.Address, endHeader *types.Header, size uint64) ([]ValueEntry, error) + func (ah *APIHelper) CandidateInfo(addr common.Address, header *types.Header) (CandidateInfo, error) + func (ah *APIHelper) CandidateVoteStat(addr common.Address, header *types.Header) ([]ValueEntry, error) + func (ah *APIHelper) GetCandidateDeposit(addr common.Address, header *types.Header) (common.BigInt, error) + func (ah *APIHelper) GetCandidates(header *types.Header) ([]common.Address, error) + func (ah *APIHelper) GetValidatorInfo(addr common.Address, header *types.Header) (ValidatorInfo, error) + func (ah *APIHelper) GetValidatorTotalVotes(addr common.Address, header *types.Header) (common.BigInt, error) + func (ah *APIHelper) GetValidators(header *types.Header) ([]common.Address, error) + func (ah *APIHelper) GetVoteDeposit(addr common.Address, header *types.Header) (common.BigInt, error) + func (ah *APIHelper) GetVotedCandidates(addr common.Address, header *types.Header) ([]common.Address, error) + func (ah *APIHelper) ValidatorRewardInRange(validator common.Address, endHeader *types.Header, size uint64) (common.BigInt, error) + func (ah *APIHelper) ValidatorVoteStat(addr common.Address, header *types.Header) ([]ValueEntry, error) + type BlockChain interface + DposCtxAt func(root *types.DposContextRoot) (*types.DposContext, error) + GetHeader func(hash common.Hash, bn uint64) *types.Header + GetHeaderByHash func(hash common.Hash) *types.Header + GetHeaderByNumber func(bn uint64) *types.Header + StateAt func(hash common.Hash) (*state.StateDB, error) + type CandidateInfo struct + Deposit common.BigInt + RewardRatio uint64 + TotalVotes common.BigInt + type Dpos struct + Mode Mode + func New(config *params.DposConfig, db ethdb.Database) *Dpos + func NewDposFaker() *Dpos + func (d *Dpos) APIs(chain consensus.ChainReader) []rpc.API + func (d *Dpos) Author(header *types.Header) (common.Address, error) + func (d *Dpos) Authorize(signer common.Address, signFn SignerFn) + func (d *Dpos) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int + func (d *Dpos) CheckValidator(lastBlock *types.Block, now int64) error + func (d *Dpos) Close() error + func (d *Dpos) Coinbase(header *types.Header) (common.Address, error) + func (d *Dpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error) + func (d *Dpos) Prepare(chain consensus.ChainReader, header *types.Header) error + func (d *Dpos) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error + func (d *Dpos) SealHash(header *types.Header) common.Hash + func (d *Dpos) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error + func (d *Dpos) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error) + func (d *Dpos) VerifySeal(chain consensus.ChainReader, header *types.Header) error + func (d *Dpos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error + type EpochContext struct + DposContext *types.DposContext + TimeStamp int64 + type Mode uint + const ModeFake + const ModeNormal + type SignerFn func(accounts.Account, []byte) ([]byte, error) + type ValidatorInfo struct + EpochID int64 + MinedCount int64 + RewardRatio uint64 + TotalVotes common.BigInt + type ValueEntry struct + Addr common.Address + Value common.BigInt