Documentation ¶
Index ¶
- Constants
- Variables
- func CalcBonus(fromTS uint64, toTS uint64, rate uint8, value *big.Int) *big.Int
- func CheckCandEnoughSelfVotes(newVotes *big.Int, c *meter.Candidate, bl *meter.BucketList, ...) bool
- func CheckEnoughSelfVotes(subVotes *big.Int, c *meter.Candidate, bl *meter.BucketList, ...) bool
- func GetBoundLockOption(chose uint32) (opt uint32, rate uint8, locktime uint64)
- func GetBoundLocktime(opt uint32) (lock uint64)
- func GetCandidateBucket(c *meter.Candidate, bl *meter.BucketList) (*meter.Bucket, error)
- func GetCandidateSelfBuckets(c *meter.Candidate, bl *meter.BucketList) ([]*meter.Bucket, error)
- func GetCommissionRate(opt uint32) uint64
- func GetOpName(op uint32) string
- func InTimeSpan(ts, now, span uint64) bool
- func TouchBucketBonus(ts uint64, bucket *meter.Bucket) *big.Int
- type Staking
- func (s *Staking) BoundHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) BucketUpdateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) CandidateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) CandidateUpdateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) Chain() *chain.Chain
- func (s *Staking) DelegateExitJailHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) DelegateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) DelegateStatFlushHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) DelegateStatHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) DoTeslaFork1_Correction(bid meter.Bytes32, owner meter.Address, amount *big.Int, state *state.State, ...)
- func (s *Staking) DoTeslaFork5_BonusCorrection(state *state.State)
- func (s *Staking) DoTeslaFork6_StakingCorrection(state *state.State)
- func (s *Staking) GoverningHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) Handle(senv *setypes.ScriptEnv, payload []byte, to *meter.Address, gas uint64) (seOutput *setypes.ScriptEngineOutput, leftOverGas uint64, err error)
- func (s *Staking) UnBoundHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) UnCandidateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- func (s *Staking) UnDelegateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
- type StakingBody
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_RATE = ONE_WEEK_LOCK_RATE FOREVER_LOCK_TIME = uint64(0) BUCKET_ADD_OPT = 0 BUCKET_SUB_OPT = 1 )
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) )
Variables ¶
View Source
var ( // bound minimium requirement 100 mtrgov MIN_BOUND_BALANCE *big.Int = new(big.Int).Mul(big.NewInt(100), big.NewInt(1e18)) MIN_SUB_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))) )
Functions ¶
func CheckCandEnoughSelfVotes ¶ added in v1.2.0
func CheckEnoughSelfVotes ¶
func GetBoundLockOption ¶
func GetBoundLocktime ¶
func GetCandidateBucket ¶ added in v1.2.0
get the bucket that candidate initialized
func GetCandidateSelfBuckets ¶ added in v1.2.0
get the buckets which owner is candidate
func GetCommissionRate ¶
func InTimeSpan ¶
Types ¶
type Staking ¶
type Staking struct {
// contains filtered or unexported fields
}
Candidate indicates the structure of a candidate
func (*Staking) BoundHandler ¶
func (*Staking) BucketUpdateHandler ¶
func (s *Staking) BucketUpdateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
update the bucket value. we can only increase the balance
func (*Staking) CandidateHandler ¶
func (*Staking) CandidateUpdateHandler ¶
func (s *Staking) CandidateUpdateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
This method only update the attached infomation of candidate. Stricted to: name, public key, IP/port, commission
func (*Staking) DelegateExitJailHandler ¶
func (*Staking) DelegateHandler ¶
func (*Staking) DelegateStatFlushHandler ¶
func (s *Staking) DelegateStatFlushHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)
this is debug API, only executor has the right to call
func (*Staking) DelegateStatHandler ¶
func (*Staking) DoTeslaFork1_Correction ¶
func (*Staking) DoTeslaFork5_BonusCorrection ¶
func (*Staking) DoTeslaFork6_StakingCorrection ¶
func (*Staking) GoverningHandler ¶
func (*Staking) UnBoundHandler ¶
func (*Staking) UnCandidateHandler ¶
func (*Staking) UnDelegateHandler ¶
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 DecodeFromBytes ¶
func DecodeFromBytes(bytes []byte) (*StakingBody, error)
func (*StakingBody) String ¶ added in v1.2.0
func (sb *StakingBody) String() string
func (*StakingBody) ToString ¶
func (sb *StakingBody) ToString() string
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)
Source Files ¶
- handler.go
- handler_bailOut.go
- handler_bound.go
- handler_bucketUpdate.go
- handler_candidate.go
- handler_candidateUpdate.go
- handler_delegate.go
- handler_govern.go
- handler_stats.go
- handler_statsFlush.go
- handler_unbound.go
- handler_uncandidate.go
- handler_undelegate.go
- option.go
- params.go
- staking_body.go
- utils.go
Click to show internal directories.
Click to hide internal directories.