Documentation ¶
Index ¶
- Constants
- Variables
- func DryRunUpdateEpochValidatorSet(state *state.StateDB, validators *tmTypes.ValidatorSet, ...) error
- func SaveEpochVoteSet(epochDB db.DB, epochNumber uint64, voteSet *EpochValidatorVoteSet)
- func UpdateEpochEndTime(db dbm.DB, epNumber uint64, endTime time.Time)
- type Epoch
- func (epoch *Epoch) Bytes() []byte
- func (epoch *Epoch) Copy() *Epoch
- func (epoch *Epoch) EnterNewEpoch(newValidators *tmTypes.ValidatorSet) (*Epoch, error)
- func (epoch *Epoch) Equals(other *Epoch, checkPrevNext bool) bool
- func (epoch *Epoch) GetDB() dbm.DB
- func (epoch *Epoch) GetEpochByBlockNumber(blockNumber uint64) *Epoch
- func (epoch *Epoch) GetEpochValidatorVoteSet() *EpochValidatorVoteSet
- func (epoch *Epoch) GetForbiddenDuration() time.Duration
- func (epoch *Epoch) GetNextEpoch() *Epoch
- func (epoch *Epoch) GetPreviousEpoch() *Epoch
- func (epoch *Epoch) GetRewardScheme() *RewardScheme
- func (epoch *Epoch) ProposeNextEpoch(lastBlockHeight uint64, lastBlockTime time.Time) *Epoch
- func (epoch *Epoch) Save()
- func (epoch *Epoch) SetNextEpoch(next *Epoch)
- func (epoch *Epoch) SetRewardScheme(rs *RewardScheme)
- func (epoch *Epoch) ShouldEnterNewEpoch(height uint64, state *state.StateDB) (bool, *tmTypes.ValidatorSet, error)
- func (epoch *Epoch) ShouldProposeNextEpoch(curBlockHeight uint64) bool
- func (epoch *Epoch) String() string
- func (epoch *Epoch) UpdateForbiddenState(header *types.Header, prevHeader *types.Header, commit *tmTypes.Commit, ...)
- func (epoch *Epoch) ValidateNextEpoch(next *Epoch, lastHeight uint64, lastBlockTime time.Time) error
- type EpochValidatorVote
- type EpochValidatorVoteSet
- func (voteSet *EpochValidatorVoteSet) Copy() *EpochValidatorVoteSet
- func (voteSet *EpochValidatorVoteSet) GetVoteByAddress(address common.Address) (vote *EpochValidatorVote, exist bool)
- func (voteSet *EpochValidatorVoteSet) IsEmpty() bool
- func (voteSet *EpochValidatorVoteSet) StoreVote(vote *EpochValidatorVote)
- type RewardScheme
Constants ¶
View Source
const ( EPOCH_NOT_EXIST = iota // value --> 0 EPOCH_PROPOSED_NOT_VOTED // value --> 1 EPOCH_VOTED_NOT_SAVED // value --> 2 EPOCH_SAVED // value --> 3 MinimumValidatorsSize = 1 MaximumValidatorsSize = 100 // TODO the max validator size will increase to 100 in the future TimeForForbidden = 4 * time.Hour ForbiddenDuration = 24 * time.Hour )
Variables ¶
View Source
var ForbiddenEpoch = big.NewInt(2) // forbid 2 epoch
View Source
var NextEpochNotEXPECTED = errors.New("next epoch parameters are not excepted, fatal error")
View Source
var NextEpochNotExist = errors.New("next epoch parameters do not exist, fatal error")
Functions ¶
func DryRunUpdateEpochValidatorSet ¶
func DryRunUpdateEpochValidatorSet(state *state.StateDB, validators *tmTypes.ValidatorSet, voteSet *EpochValidatorVoteSet) error
DryRunUpdateEpochValidatorSet Re-calculate the New Validator Set base on the current state db and vote set
func SaveEpochVoteSet ¶
func SaveEpochVoteSet(epochDB db.DB, epochNumber uint64, voteSet *EpochValidatorVoteSet)
Types ¶
type Epoch ¶
type Epoch struct { Number uint64 RewardPerBlock *big.Int StartBlock uint64 EndBlock uint64 StartTime time.Time EndTime time.Time //not accurate for current epoch BlockGenerated int //agreed in which block Status int //checked if this epoch has been saved Validators *tmTypes.ValidatorSet // contains filtered or unexported fields }
func LoadOneEpoch ¶
Load Full Epoch By EpochNumber (Epoch data, Reward Scheme, ValidatorVote, Previous Epoch, Next Epoch)
func MakeOneEpoch ¶
Convert from OneEpochDoc (Json) to Epoch
func (*Epoch) EnterNewEpoch ¶
func (epoch *Epoch) EnterNewEpoch(newValidators *tmTypes.ValidatorSet) (*Epoch, error)
Move to New Epoch
func (*Epoch) GetEpochByBlockNumber ¶
func (*Epoch) GetEpochValidatorVoteSet ¶
func (epoch *Epoch) GetEpochValidatorVoteSet() *EpochValidatorVoteSet
func (*Epoch) GetForbiddenDuration ¶
func (*Epoch) GetNextEpoch ¶
func (*Epoch) GetPreviousEpoch ¶
func (*Epoch) GetRewardScheme ¶
func (epoch *Epoch) GetRewardScheme() *RewardScheme
func (*Epoch) ProposeNextEpoch ¶
func (*Epoch) SetNextEpoch ¶
func (*Epoch) SetRewardScheme ¶
func (epoch *Epoch) SetRewardScheme(rs *RewardScheme)
func (*Epoch) ShouldEnterNewEpoch ¶
func (*Epoch) ShouldProposeNextEpoch ¶
check if need propose next epoch
type EpochValidatorVote ¶
type EpochValidatorVote struct { Address common.Address PubKey crypto.PubKey Amount *big.Int Salt string VoteHash common.Hash // VoteHash = Sha3(Address + PubKey + Amount + Salt) TxHash common.Hash }
func (*EpochValidatorVote) Copy ¶
func (vote *EpochValidatorVote) Copy() *EpochValidatorVote
type EpochValidatorVoteSet ¶
type EpochValidatorVoteSet struct { // Store the Votes Votes []*EpochValidatorVote // contains filtered or unexported fields }
func LoadEpochVoteSet ¶
func LoadEpochVoteSet(epochDB db.DB, epochNumber uint64) *EpochValidatorVoteSet
func NewEpochValidatorVoteSet ¶
func NewEpochValidatorVoteSet() *EpochValidatorVoteSet
func (*EpochValidatorVoteSet) Copy ¶
func (voteSet *EpochValidatorVoteSet) Copy() *EpochValidatorVoteSet
func (*EpochValidatorVoteSet) GetVoteByAddress ¶
func (voteSet *EpochValidatorVoteSet) GetVoteByAddress(address common.Address) (vote *EpochValidatorVote, exist bool)
GetVoteByAddress get the Vote from VoteSet by Address Hex Key
func (*EpochValidatorVoteSet) IsEmpty ¶
func (voteSet *EpochValidatorVoteSet) IsEmpty() bool
func (*EpochValidatorVoteSet) StoreVote ¶
func (voteSet *EpochValidatorVoteSet) StoreVote(vote *EpochValidatorVote)
StoreVote insert or update the Vote into VoteSet by Address Hex Key
type RewardScheme ¶
type RewardScheme struct { TotalReward *big.Int RewardFirstYear *big.Int EpochNumberPerYear uint64 TotalYear uint64 // contains filtered or unexported fields }
func MakeRewardScheme ¶
func MakeRewardScheme(db dbm.DB, rsDoc *tmTypes.RewardSchemeDoc) *RewardScheme
Convert Reward Scheme from json to struct
func (*RewardScheme) String ¶
func (rs *RewardScheme) String() string
Click to show internal directories.
Click to hide internal directories.