staking

package
v1.2.0-fix10 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: LGPL-3.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ONE_DAY_LOCK      = uint32(0)
	ONE_DAY_LOCK_RATE = uint8(0)
	ONE_DAY_LOCK_TIME = uint64(60 * 60 * 24)

	ONE_WEEK_LOCK      = uint32(1)
	ONE_WEEK_LOCK_RATE = uint8(5) // 5 percent
	ONE_WEEK_LOCK_TIME = uint64(60 * 60 * 24 * 7)

	TWO_WEEK_LOCK      = uint32(2)
	TWO_WEEK_LOCK_RATE = uint8(6) // %6
	TWO_WEEK_LOCK_TIME = uint64(60 * 60 * 24 * 14)

	THREE_WEEK_LOCK      = uint32(3)
	THREE_WEEK_LOCK_RATE = uint8(7)
	THREE_WEEK_LOCK_TIME = uint64(60 * 60 * 24 * 21)

	FOUR_WEEK_LOCK      = uint32(4)
	FOUR_WEEK_LOCK_RATE = uint8(8)
	FOUR_WEEK_LOCK_TIME = uint64(60 * 60 * 24 * 28)

	// for candidate bucket ONLY
	FOREVER_LOCK      = uint32(1000)
	FOREVER_LOCK_RATE = ONE_WEEK_LOCK_RATE
	FOREVER_LOCK_TIME = uint64(0)
)

staking options

View Source
const (
	MIN_CANDIDATE_UPDATE_INTV = uint64(3600 * 24) // 1 day
	TESLA1_0_SELF_VOTE_RATIO  = 10                // max candidate total votes / self votes ratio < 10x in Tesla 1.0
	TESLA1_1_SELF_VOTE_RATIO  = 100               // max candidate total votes / self votes ratio < 100x in Tesla 1.1

	STAKING_TIMESPAN = uint64(720)
)
View Source
const (
	OP_BOUND          = uint32(1)
	OP_UNBOUND        = uint32(2)
	OP_CANDIDATE      = uint32(3)
	OP_UNCANDIDATE    = uint32(4)
	OP_DELEGATE       = uint32(5)
	OP_UNDELEGATE     = uint32(6)
	OP_CANDIDATE_UPDT = uint32(7)
	OP_BUCKET_UPDT    = uint32(8)

	OP_DELEGATE_STATISTICS  = uint32(101)
	OP_DELEGATE_EXITJAIL    = uint32(102)
	OP_FLUSH_ALL_STATISTICS = uint32(103)

	OP_GOVERNING = uint32(10001)
)
View Source
const (
	JailCriteria = 2000 // 100 times of missing proposer (roughly 2 epoch of misconducting, when 1 epoch = 1 hour)

	DoubleSignPts      = 2000
	MissingLeaderPts   = 1000
	MissingProposerPts = 20
	MissingVoterPts    = 2

	PhaseOutEpochCount    = 4 // half points after 12 epoch (half a day)
	PhaseOutDoubleSignPts = DoubleSignPts / 2
	PhaseOutLeaderPts     = MissingLeaderPts / 2
	PhaseOutProposerPts   = MissingProposerPts / 2
	PhaseOutVoterPts      = MissingVoterPts / 2
	WipeOutEpochCount     = PhaseOutEpochCount * 2 // does not count if longer than 2*PhaseOutEpochOut

	NObservationEpochs = 8 // Only the last 8 epochs are used to calculate violation count

	MaxMissingProposerPerEpoch = 3 // if 3 missing proposers or more infractions in one epoch, violation is raised
	MaxMissingLeaderPerEpoch   = 2
	MaxDoubleSignPerEpoch      = 1

	JailCriteria_MissingProposerViolation = 2 // only 2 times of missing-proposer-epoch violation is allowed,
	JailCriteria_MissingLeaderViolation   = 2
	JailCriteria_DoubleSignViolation      = 1
)
View Source
const (
	STAKING_MAX_VALIDATOR_REWARDS = 32
)

Variables

View Source
var (
	// bound minimium requirement 100 mtrgov
	MIN_BOUND_BALANCE *big.Int = new(big.Int).Mul(big.NewInt(100), big.NewInt(1e18))

	// delegate minimum requirement 2000 MTRG
	MIN_REQUIRED_BY_DELEGATE *big.Int = new(big.Int).Mul(big.NewInt(int64(2000)), big.NewInt(int64(1e18)))

	// amount to exit from jail 10 MTRGov
	BAIL_FOR_EXIT_JAIL *big.Int = new(big.Int).Mul(big.NewInt(int64(10)), big.NewInt(int64(1e18)))
)
View Source
var (
	StakingModuleAddr      = meter.BytesToAddress([]byte("staking-module-address")) // 0x616B696e672D6D6F64756c652d61646472657373
	DelegateListKey        = meter.Blake2b([]byte("delegate-list-key"))
	CandidateListKey       = meter.Blake2b([]byte("candidate-list-key"))
	StakeHolderListKey     = meter.Blake2b([]byte("stake-holder-list-key"))
	BucketListKey          = meter.Blake2b([]byte("global-bucket-list-key"))
	StatisticsListKey      = meter.Blake2b([]byte("delegate-statistics-list-key"))
	StatisticsEpochKey     = meter.Blake2b([]byte("delegate-statistics-epoch-key"))
	InJailListKey          = meter.Blake2b([]byte("delegate-injail-list-key"))
	ValidatorRewardListKey = meter.Blake2b([]byte("validator-reward-list-key"))
)

Functions

func CheckCandEnoughSelfVotes added in v1.2.0

func CheckCandEnoughSelfVotes(newVotes *big.Int, c *Candidate, bl *BucketList, selfVoteRatio int64) bool

func GetBoundLockOption

func GetBoundLockOption(chose uint32) (opt uint32, rate uint8, locktime uint64)

func GetBoundLocktime

func GetBoundLocktime(opt uint32) (lock uint64)

func GetCommissionRate

func GetCommissionRate(opt uint32) uint64

func GetInternalDelegateList

func GetInternalDelegateList() ([]*types.DelegateIntern, error)

consensus routine interface

func GetOpName

func GetOpName(op uint32) string

func InTimeSpan

func InTimeSpan(ts, now, span uint64) bool

func PackInfractionToBytes

func PackInfractionToBytes(v *Infraction) ([]byte, error)

func SetStakingGlobInst

func SetStakingGlobInst(inst *Staking)

func StakingEncodeBytes

func StakingEncodeBytes(sb *StakingBody) []byte

func TouchBucketBonus added in v1.2.0

func TouchBucketBonus(ts uint64, bucket *Bucket) *big.Int

Types

type Bucket

type Bucket struct {
	BucketID   meter.Bytes32
	Owner      meter.Address // stake holder
	Nonce      uint64        // nonce
	CreateTime uint64        // bucket create time

	//non-key fields
	Value        *big.Int      // staking unit Wei
	Token        uint8         // token type MTR / MTRG
	Unbounded    bool          // this bucket is unbounded, get rid of it after mature
	Candidate    meter.Address // candidate
	Rate         uint8         // bounus rate
	Autobid      uint8         // autobid percentile
	Option       uint32        // option, link with rate
	BonusVotes   uint64        // extra votes from staking
	TotalVotes   *big.Int      // Value votes + extra votes
	MatureTime   uint64        // time durations, seconds
	CalcLastTime uint64        // last calculate bounus votes timestamp
}

Candidate indicates the structure of a candidate

func GetCandidateBucket added in v1.2.0

func GetCandidateBucket(c *Candidate, bl *BucketList) (*Bucket, error)

get the bucket that candidate initialized

func GetCandidateSelfBuckets added in v1.2.0

func GetCandidateSelfBuckets(c *Candidate, bl *BucketList) ([]*Bucket, error)

get the buckets which owner is candidate

func NewBucket

func NewBucket(owner meter.Address, cand meter.Address, value *big.Int, token uint8, opt uint32, rate uint8, autobid uint8, create uint64, nonce uint64) *Bucket

func (*Bucket) ID

func (b *Bucket) ID() (hash meter.Bytes32)

bucketID Candidate .. are excluded value and token are excluded since are allowed to change

func (*Bucket) IsForeverLock

func (b *Bucket) IsForeverLock() bool

func (*Bucket) ToString

func (b *Bucket) ToString() string

func (*Bucket) UpdateLockOption

func (b *Bucket) UpdateLockOption(opt uint32, rate uint8)

type BucketList

type BucketList struct {
	// contains filtered or unexported fields
}

func GetBucketListByHeader added in v1.2.0

func GetBucketListByHeader(header *block.Header) (*BucketList, error)

func GetLatestBucketList

func GetLatestBucketList() (*BucketList, error)

func (*BucketList) Add

func (l *BucketList) Add(b *Bucket)

func (*BucketList) Exist

func (l *BucketList) Exist(id meter.Bytes32) bool

func (*BucketList) Get

func (l *BucketList) Get(id meter.Bytes32) *Bucket

func (*BucketList) Remove

func (l *BucketList) Remove(id meter.Bytes32)

func (*BucketList) ToList

func (l *BucketList) ToList() []Bucket

func (*BucketList) ToString

func (l *BucketList) ToString() string

type Candidate

type Candidate struct {
	Addr        meter.Address // the address for staking / reward
	Name        []byte
	Description []byte
	PubKey      []byte // node public key
	IPAddr      []byte // network addr
	Port        uint16
	Commission  uint64          // unit shannon, aka 1e09
	Timestamp   uint64          // last update time
	TotalVotes  *big.Int        // total voting from all buckets
	Buckets     []meter.Bytes32 // all buckets voted for this candidate
}

Candidate indicates the structure of a candidate

func NewCandidate

func NewCandidate(addr meter.Address, name []byte, desc []byte, pubKey []byte, ip []byte, port uint16,
	commission uint64, timeStamp uint64) *Candidate

func (*Candidate) AddBucket

func (c *Candidate) AddBucket(bucket *Bucket)

func (*Candidate) RemoveBucket

func (c *Candidate) RemoveBucket(bucket *Bucket)

func (*Candidate) ToString

func (c *Candidate) ToString() string

type CandidateList

type CandidateList struct {
	// contains filtered or unexported fields
}

func GetCandidateListByHeader added in v1.2.0

func GetCandidateListByHeader(header *block.Header) (*CandidateList, error)

func GetLatestCandidateList

func GetLatestCandidateList() (*CandidateList, error)

api routine interface

func NewCandidateList

func NewCandidateList(candidates []*Candidate) *CandidateList

func (*CandidateList) Add

func (cl *CandidateList) Add(c *Candidate)

func (*CandidateList) Count

func (cl *CandidateList) Count() int

func (*CandidateList) Exist

func (cl *CandidateList) Exist(addr meter.Address) bool

func (*CandidateList) Get

func (cl *CandidateList) Get(addr meter.Address) *Candidate

func (*CandidateList) Remove

func (cl *CandidateList) Remove(addr meter.Address)

func (*CandidateList) ToList

func (l *CandidateList) ToList() []Candidate

func (*CandidateList) ToString

func (cl *CandidateList) ToString() string

type Delegate

type Delegate struct {
	Address     meter.Address
	PubKey      []byte //ecdsa.PublicKey
	Name        []byte
	VotingPower *big.Int
	IPAddr      []byte
	Port        uint16
	Commission  uint64 // commission rate. unit shannon, aka, 1e09
	DistList    []*Distributor
}

====

func (*Delegate) MinimumRequirements

func (d *Delegate) MinimumRequirements(state *state.State) bool

match minimum requirements? 1. not on injail list 2. > 300 MTRG

func (*Delegate) ToString

func (d *Delegate) ToString() string

type DelegateInJailList

type DelegateInJailList struct {
	// contains filtered or unexported fields
}

func GetLatestInJailList

func GetLatestInJailList() (*DelegateInJailList, error)

api routine interface

func NewDelegateInJailList

func NewDelegateInJailList(in []*DelegateJailed) *DelegateInJailList

func (*DelegateInJailList) Add

func (dl *DelegateInJailList) Add(c *DelegateJailed)

func (*DelegateInJailList) Count

func (dl *DelegateInJailList) Count() int

func (*DelegateInJailList) Exist

func (dl *DelegateInJailList) Exist(addr meter.Address) bool

func (*DelegateInJailList) Get

func (*DelegateInJailList) Remove

func (dl *DelegateInJailList) Remove(addr meter.Address) error

func (*DelegateInJailList) ToList

func (dl *DelegateInJailList) ToList() []DelegateJailed

func (*DelegateInJailList) ToString

func (dl *DelegateInJailList) ToString() string

type DelegateJailed

type DelegateJailed struct {
	Addr        meter.Address // the address for staking / reward
	Name        []byte
	PubKey      []byte // node public key
	TotalPts    uint64 // total points of infraction
	Infractions Infraction
	BailAmount  *big.Int //fine
	JailedTime  uint64
}

Candidate indicates the structure of a candidate

func NewDelegateJailed

func NewDelegateJailed(addr meter.Address, name []byte, pubKey []byte, pts uint64, inf *Infraction, bail *big.Int, timeStamp uint64) *DelegateJailed

func (*DelegateJailed) ToString

func (d *DelegateJailed) ToString() string

type DelegateList

type DelegateList struct {
	// contains filtered or unexported fields
}

func GetLatestDelegateList

func GetLatestDelegateList() (*DelegateList, error)

api routine interface

func (*DelegateList) Add

func (l *DelegateList) Add(c *Delegate) error

func (*DelegateList) CleanAll

func (l *DelegateList) CleanAll() error

func (*DelegateList) GetDelegates

func (l *DelegateList) GetDelegates() []*Delegate

func (*DelegateList) Members

func (l *DelegateList) Members() string

func (*DelegateList) SetDelegates

func (l *DelegateList) SetDelegates(delegates []*Delegate)

func (*DelegateList) ToString

func (l *DelegateList) ToString() string

type DelegateStatistics

type DelegateStatistics struct {
	Addr        meter.Address // the address for staking / reward
	Name        []byte
	PubKey      []byte // node public key
	TotalPts    uint64 // total points of infraction
	Infractions Infraction
}

Candidate indicates the structure of a candidate

func NewDelegateStatistics

func NewDelegateStatistics(addr meter.Address, name []byte, pubKey []byte) *DelegateStatistics

func (*DelegateStatistics) CountDoubleSignViolation added in v1.2.0

func (ds *DelegateStatistics) CountDoubleSignViolation(epoch uint32) int

func (*DelegateStatistics) CountMissingLeaderViolation added in v1.2.0

func (ds *DelegateStatistics) CountMissingLeaderViolation(epoch uint32) int

func (*DelegateStatistics) CountMissingProposerViolation added in v1.2.0

func (ds *DelegateStatistics) CountMissingProposerViolation(epoch uint32) int

func (*DelegateStatistics) PhaseOut

func (ds *DelegateStatistics) PhaseOut(curEpoch uint32)

func (*DelegateStatistics) ToString

func (ds *DelegateStatistics) ToString() string

func (*DelegateStatistics) Update

func (ds *DelegateStatistics) Update(incr *Infraction)

type Distributor

type Distributor struct {
	Address meter.Address
	Autobid uint8  // autobid percentile
	Shares  uint64 // unit shannon, aka, 1e09
}

func NewDistributor

func NewDistributor(addr meter.Address, autobid uint8, shares uint64) *Distributor

func (*Distributor) ToString

func (d *Distributor) ToString() string

type DoubleSigner

type DoubleSigner struct {
	Counter uint32
	Info    []*DoubleSignerInfo
}

type DoubleSignerInfo

type DoubleSignerInfo struct {
	Epoch  uint32
	Height uint32
}

DoubleSigner

type Infraction

type Infraction struct {
	MissingLeaders   MissingLeader
	MissingProposers MissingProposer
	MissingVoters    MissingVoter
	DoubleSigners    DoubleSigner
}

func UnpackBytesToInfraction

func UnpackBytesToInfraction(b []byte) (*Infraction, error)

func (*Infraction) String

func (inf *Infraction) String() string

type MissingLeader

type MissingLeader struct {
	Counter uint32
	Info    []*MissingLeaderInfo
}

type MissingLeaderInfo

type MissingLeaderInfo struct {
	Epoch uint32
	Round uint32
}

MissingLeader

type MissingProposer

type MissingProposer struct {
	Counter uint32
	Info    []*MissingProposerInfo
}

func (MissingProposer) String added in v1.2.0

func (m MissingProposer) String() string

type MissingProposerInfo

type MissingProposerInfo struct {
	Epoch  uint32
	Height uint32
}

MissingProposer

type MissingVoter

type MissingVoter struct {
	Counter uint32
	Info    []*MissingVoterInfo
}

type MissingVoterInfo

type MissingVoterInfo struct {
	Epoch  uint32
	Height uint32
}

MissingVoter

type RewardInfo

type RewardInfo struct {
	Address meter.Address
	Amount  *big.Int
}

func (*RewardInfo) String added in v1.2.0

func (ri *RewardInfo) String() string

func (*RewardInfo) ToString added in v1.2.0

func (ri *RewardInfo) ToString() string

func (*RewardInfo) UniteHash added in v1.2.0

func (sb *RewardInfo) UniteHash() (hash meter.Bytes32)

type Stakeholder

type Stakeholder struct {
	Holder     meter.Address   // the address for staking / reward
	TotalStake *big.Int        // total voting from all buckets
	Buckets    []meter.Bytes32 // all buckets voted for this Stakeholder
}

Stakeholder indicates the structure of a Stakeholder

func NewStakeholder

func NewStakeholder(holder meter.Address) *Stakeholder

func (*Stakeholder) AddBucket

func (s *Stakeholder) AddBucket(bucket *Bucket)

func (*Stakeholder) RemoveBucket

func (s *Stakeholder) RemoveBucket(bucket *Bucket)

func (*Stakeholder) ToString

func (s *Stakeholder) ToString() string

type StakeholderList

type StakeholderList struct {
	// contains filtered or unexported fields
}

func GetLatestStakeholderList

func GetLatestStakeholderList() (*StakeholderList, error)

func GetStakeholderListByHeader added in v1.2.0

func GetStakeholderListByHeader(header *block.Header) (*StakeholderList, error)

func (*StakeholderList) Add

func (l *StakeholderList) Add(s *Stakeholder)

func (*StakeholderList) Exist

func (l *StakeholderList) Exist(addr meter.Address) bool

func (*StakeholderList) Get

func (l *StakeholderList) Get(addr meter.Address) *Stakeholder

func (*StakeholderList) Remove

func (l *StakeholderList) Remove(addr meter.Address)

func (*StakeholderList) ToList

func (l *StakeholderList) ToList() []Stakeholder

func (*StakeholderList) ToString

func (l *StakeholderList) ToString() string

type Staking

type Staking struct {
	// contains filtered or unexported fields
}

Candidate indicates the structure of a candidate

var (
	StakingGlobInst *Staking
)

func GetStakingGlobInst

func GetStakingGlobInst() *Staking

func NewStaking

func NewStaking(ch *chain.Chain, sc *state.Creator) *Staking

func (*Staking) BoundAccountMeter

func (s *Staking) BoundAccountMeter(addr meter.Address, amount *big.Int, state *state.State, env *StakingEnv) error

==================== bound/unbound account ===========================

func (*Staking) BoundAccountMeterGov

func (s *Staking) BoundAccountMeterGov(addr meter.Address, amount *big.Int, state *state.State, env *StakingEnv) error

bound a meter gov in an account -- move amount from balance to bounded balance

func (*Staking) CollectBailMeterGov

func (s *Staking) CollectBailMeterGov(addr meter.Address, amount *big.Int, state *state.State, env *StakingEnv) error

collect bail to StakingModuleAddr. addr ==> StakingModuleAddr

func (*Staking) DistValidatorRewards

func (s *Staking) DistValidatorRewards(rinfo []*RewardInfo, state *state.State, env *StakingEnv) (*big.Int, error)

func (*Staking) EnforceTeslaFor1_1Correction added in v1.2.0

func (staking *Staking) EnforceTeslaFor1_1Correction(bid meter.Bytes32, owner meter.Address, amount *big.Int, state *state.State, ts uint64)

func (*Staking) GetBucketList

func (s *Staking) GetBucketList(state *state.State) (result *BucketList)

Bucket List

func (*Staking) GetCandidateList

func (s *Staking) GetCandidateList(state *state.State) (result *CandidateList)

Candidate List

func (*Staking) GetDelegateList

func (s *Staking) GetDelegateList(state *state.State) (result *DelegateList)

Delegates List

func (*Staking) GetInJailList

func (s *Staking) GetInJailList(state *state.State) (result *DelegateInJailList)

inJail List

func (*Staking) GetStakeHolderList

func (s *Staking) GetStakeHolderList(state *state.State) (result *StakeholderList)

StakeHolder List

func (*Staking) GetStatisticsEpoch

func (s *Staking) GetStatisticsEpoch(state *state.State) (result uint32)

Statistics List, unlike others, save/get list

func (*Staking) GetStatisticsList

func (s *Staking) GetStatisticsList(state *state.State) (result *StatisticsList)

==== Statistics List, unlike others, save/get list

func (*Staking) GetValidatorRewardList

func (s *Staking) GetValidatorRewardList(state *state.State) (result *ValidatorRewardList)

validator reward list

func (*Staking) PrepareStakingHandler

func (s *Staking) PrepareStakingHandler() (StakingHandler func([]byte, *meter.Address, *xenv.TransactionContext, uint64, *state.State) (*setypes.ScriptEngineOutput, uint64, error))

func (*Staking) SetBucketList

func (s *Staking) SetBucketList(bucketList *BucketList, state *state.State)

func (*Staking) SetCandidateList

func (s *Staking) SetCandidateList(candList *CandidateList, state *state.State)

func (*Staking) SetDelegateList

func (s *Staking) SetDelegateList(delegateList *DelegateList, state *state.State)

func (*Staking) SetInJailList

func (s *Staking) SetInJailList(list *DelegateInJailList, state *state.State)

func (*Staking) SetStakeHolderList

func (s *Staking) SetStakeHolderList(holderList *StakeholderList, state *state.State)

func (*Staking) SetStatisticsEpoch

func (s *Staking) SetStatisticsEpoch(phaseOutEpoch uint32, state *state.State)

func (*Staking) SetStatisticsList

func (s *Staking) SetStatisticsList(list *StatisticsList, state *state.State)

func (*Staking) SetValidatorRewardList

func (s *Staking) SetValidatorRewardList(list *ValidatorRewardList, state *state.State)

func (*Staking) Start

func (s *Staking) Start() error

func (*Staking) TransferValidatorReward

func (s *Staking) TransferValidatorReward(amount *big.Int, addr meter.Address, state *state.State, env *StakingEnv) error

m meter.ValidatorBenefitAddr ==> addr

func (*Staking) UnboundAccountMeter

func (s *Staking) UnboundAccountMeter(addr meter.Address, amount *big.Int, state *state.State, env *StakingEnv) error

func (*Staking) UnboundAccountMeterGov

func (s *Staking) UnboundAccountMeterGov(addr meter.Address, amount *big.Int, state *state.State, env *StakingEnv) error

unbound a meter gov in an account -- move amount from bounded balance to balance

type StakingBody

type StakingBody struct {
	Opcode          uint32
	Version         uint32
	Option          uint32
	HolderAddr      meter.Address
	CandAddr        meter.Address
	CandName        []byte
	CandDescription []byte
	CandPubKey      []byte //ecdsa.PublicKey
	CandIP          []byte
	CandPort        uint16
	StakingID       meter.Bytes32 // only for unbond
	Amount          *big.Int
	Token           byte   // meter or meter gov
	Autobid         uint8  // autobid percentile
	Timestamp       uint64 // staking timestamp
	Nonce           uint64 //staking nonce
	ExtraData       []byte
}

Candidate indicates the structure of a candidate

func StakingDecodeFromBytes

func StakingDecodeFromBytes(bytes []byte) (*StakingBody, error)

func (*StakingBody) BoundHandler

func (sb *StakingBody) BoundHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) BucketUpdateHandler added in v1.2.0

func (sb *StakingBody) BucketUpdateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

update the bucket value. we can only increase the balance

func (*StakingBody) CandidateHandler

func (sb *StakingBody) CandidateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) CandidateUpdateHandler

func (sb *StakingBody) CandidateUpdateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

This method only update the attached infomation of candidate. Stricted to: name, public key, IP/port, commission

func (*StakingBody) DelegateExitJailHandler

func (sb *StakingBody) DelegateExitJailHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) DelegateHandler

func (sb *StakingBody) DelegateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) DelegateStatisticsFlushHandler

func (sb *StakingBody) DelegateStatisticsFlushHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

this is debug API, only executor has the right to call

func (*StakingBody) DelegateStatisticsHandler

func (sb *StakingBody) DelegateStatisticsHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) GoverningHandler

func (sb *StakingBody) GoverningHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) String added in v1.2.0

func (sb *StakingBody) String() string

func (*StakingBody) ToString

func (sb *StakingBody) ToString() string

func (*StakingBody) UnBoundHandler

func (sb *StakingBody) UnBoundHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) UnCandidateHandler

func (sb *StakingBody) UnCandidateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) UnDelegateHandler

func (sb *StakingBody) UnDelegateHandler(env *StakingEnv, gas uint64) (leftOverGas uint64, err error)

func (*StakingBody) UniteHash added in v1.2.0

func (sb *StakingBody) UniteHash() (hash meter.Bytes32)

func (*StakingBody) UniteHashWithoutExtraData added in v1.2.0

func (sb *StakingBody) UniteHashWithoutExtraData() (hash meter.Bytes32)

type StakingEnv added in v1.2.0

type StakingEnv struct {
	*setypes.ScriptEnv
	// contains filtered or unexported fields
}

func NewStakingEnv added in v1.2.0

func NewStakingEnv(staking *Staking, state *state.State, txCtx *xenv.TransactionContext, to *meter.Address) *StakingEnv

func (*StakingEnv) GetStaking added in v1.2.0

func (env *StakingEnv) GetStaking() *Staking

type StatisticsList

type StatisticsList struct {
	// contains filtered or unexported fields
}

func GetLatestStatisticsList

func GetLatestStatisticsList() (*StatisticsList, error)

func NewStatisticsList

func NewStatisticsList(delegates []*DelegateStatistics) *StatisticsList

func (*StatisticsList) Add

func (sl *StatisticsList) Add(c *DelegateStatistics)

func (*StatisticsList) Count

func (sl *StatisticsList) Count() int

func (*StatisticsList) Exist

func (sl *StatisticsList) Exist(addr meter.Address) bool

func (*StatisticsList) Get

func (*StatisticsList) Remove

func (sl *StatisticsList) Remove(addr meter.Address)

func (*StatisticsList) ToList

func (sl *StatisticsList) ToList() []DelegateStatistics

func (*StatisticsList) ToString

func (sl *StatisticsList) ToString() string

type ValidatorReward

type ValidatorReward struct {
	Epoch       uint32
	BaseReward  *big.Int
	TotalReward *big.Int
	Rewards     []*RewardInfo
}

func (*ValidatorReward) ToString

func (v *ValidatorReward) ToString() string

type ValidatorRewardList

type ValidatorRewardList struct {
	// contains filtered or unexported fields
}

func GetValidatorRewardListByHeader added in v1.2.0

func GetValidatorRewardListByHeader(header *block.Header) (*ValidatorRewardList, error)

api routine interface

func NewValidatorRewardList

func NewValidatorRewardList(rewards []*ValidatorReward) *ValidatorRewardList

func (*ValidatorRewardList) Count

func (v *ValidatorRewardList) Count() int

func (*ValidatorRewardList) Get

func (*ValidatorRewardList) GetList

func (v *ValidatorRewardList) GetList() []*ValidatorReward

func (*ValidatorRewardList) Last added in v1.2.0

func (*ValidatorRewardList) String

func (v *ValidatorRewardList) String() string

func (*ValidatorRewardList) ToList

func (v *ValidatorRewardList) ToList() []*ValidatorReward

func (*ValidatorRewardList) ToString

func (v *ValidatorRewardList) ToString() string

Jump to

Keyboard shortcuts

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