staking

package
v1.2.0-fork8-fix4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: LGPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

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

This section is empty.

Functions

func CalcBonus

func CalcBonus(fromTS uint64, toTS uint64, rate uint8, value *big.Int) *big.Int

func CheckCandEnoughSelfVotes added in v1.2.0

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

func CheckEnoughSelfVotes

func CheckEnoughSelfVotes(subVotes *big.Int, c *meter.Candidate, bl *meter.BucketList, selfVoteRatio int64) bool

func CorrectCheckEnoughSelfVotes

func CorrectCheckEnoughSelfVotes(c *meter.Candidate, bl *meter.BucketList, selfVoteRatio int64, addSelfValue *big.Int, subSelfValue *big.Int, addTotalValue *big.Int, subTotalValue *big.Int) bool

func GetCandidateBucket added in v1.2.0

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

get the bucket that candidate initialized

func GetCandidateSelfBuckets added in v1.2.0

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

get the buckets which owner is candidate

func GetOpName

func GetOpName(op uint32) string

func InTimeSpan

func InTimeSpan(ts, now, span uint64) bool

func TouchBucketBonus added in v1.2.0

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

deprecated warning: BonusVotes will always be 0 after Tesla Fork 5

Types

type Staking

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

Candidate indicates the structure of a candidate

func NewStaking

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

func (*Staking) BoundHandler

func (s *Staking) BoundHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

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 (s *Staking) CandidateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

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) Chain

func (s *Staking) Chain() *chain.Chain

func (*Staking) DelegateExitJailHandler

func (s *Staking) DelegateExitJailHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

func (*Staking) DelegateHandler

func (s *Staking) DelegateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

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 (s *Staking) DelegateStatHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

func (*Staking) DoTeslaFork1_Correction

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

func (*Staking) DoTeslaFork5_BonusCorrection

func (s *Staking) DoTeslaFork5_BonusCorrection(state *state.State)

func (*Staking) DoTeslaFork6_StakingCorrection

func (s *Staking) DoTeslaFork6_StakingCorrection(state *state.State)

func (*Staking) GoverningHandler

func (s *Staking) GoverningHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

func (*Staking) Handle

func (s *Staking) Handle(senv *setypes.ScriptEnv, payload []byte, to *meter.Address, gas uint64) (seOutput *setypes.ScriptEngineOutput, leftOverGas uint64, err error)

func (*Staking) UnBoundHandler

func (s *Staking) UnBoundHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

func (*Staking) UnCandidateHandler

func (s *Staking) UnCandidateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

func (*Staking) UnDelegateHandler

func (s *Staking) UnDelegateHandler(env *setypes.ScriptEnv, sb *StakingBody, gas uint64) (leftOverGas uint64, err error)

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)

Jump to

Keyboard shortcuts

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