staking

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CanBasePrefixStr           = "CanBase"
	CanMutablePrefixStr        = "CanMut"
	CanPowerPrefixStr          = "Power"
	UnStakeCountKeyStr         = "UnStakeCount"
	UnStakeItemKeyStr          = "UnStakeItem"
	DelegatePrefixStr          = "Del"
	DelegationLockPrefixStr    = "DelegationLock"
	EpochIndexKeyStr           = "EpochIndex"
	EpochValArrPrefixStr       = "EpochValArr"
	RoundIndexKeyStr           = "RoundIndex"
	RoundValArrPrefixStr       = "RoundValArr"
	AccountStakeRcPrefixStr    = "AccStakeRc"
	PPOSHASHStr                = "PPOSHASH"
	RoundValAddrArrPrefixStr   = "RoundValAddrArr"
	RoundAddrBoundaryPrefixStr = "RoundAddrBoundary"
)
View Source
const (
	MaxExternalIdLen = 70
	MaxNodeNameLen   = 30
	MaxWebsiteLen    = 140
	MaxDetailsLen    = 280
)

Variables

View Source
var (
	CanBaseKeyPrefix        = []byte(CanBasePrefixStr)
	CanMutableKeyPrefix     = []byte(CanMutablePrefixStr)
	CanPowerKeyPrefix       = []byte(CanPowerPrefixStr)
	UnStakeCountKey         = []byte(UnStakeCountKeyStr)
	UnStakeItemKey          = []byte(UnStakeItemKeyStr)
	DelegateKeyPrefix       = []byte(DelegatePrefixStr)
	DelegationLockKeyPrefix = []byte(DelegationLockPrefixStr)
	EpochIndexKey           = []byte(EpochIndexKeyStr)
	EpochValArrPrefix       = []byte(EpochValArrPrefixStr)
	RoundIndexKey           = []byte(RoundIndexKeyStr)
	RoundValArrPrefix       = []byte(RoundValArrPrefixStr)
	AccountStakeRcPrefix    = []byte(AccountStakeRcPrefixStr)
	PPOSHASHKey             = []byte(PPOSHASHStr)
	RoundValAddrArrPrefix   = []byte(RoundValAddrArrPrefixStr)
	RoundAddrBoundaryPrefix = []byte(RoundAddrBoundaryPrefixStr)
)
View Source
var (
	ErrWrongBlsPubKey               = common.NewBizError(301000, "Invalid BLS public key length")
	ErrWrongBlsPubKeyProof          = common.NewBizError(301001, "The BLS proof is incorrect")
	ErrDescriptionLen               = common.NewBizError(301002, "The Description length is incorrect")
	ErrWrongProgramVersionSign      = common.NewBizError(301003, "The program version signature is invalid")
	ErrProgramVersionTooLow         = common.NewBizError(301004, "The program version is too low")
	ErrDeclVsFialedCreateCan        = common.NewBizError(301005, "The Version Declaration is failed when creating staking")
	ErrNoSameStakingAddr            = common.NewBizError(301006, "The address must be the same as the one initiated staking")
	ErrInvalidRewardPer             = common.NewBizError(301007, "Invalid param RewardPer")
	ErrRewardPerInterval            = common.NewBizError(301008, "Modify the commission reward ratio too frequently")
	ErrRewardPerChangeRange         = common.NewBizError(301009, "The modification range exceeds the limit")
	ErrStakeVonTooLow               = common.NewBizError(301100, "Staking deposit is insufficient")
	ErrCanAlreadyExist              = common.NewBizError(301101, "The candidate already existed")
	ErrCanNoExist                   = common.NewBizError(301102, "The candidate does not exist")
	ErrCanStatusInvalid             = common.NewBizError(301103, "This candidate status is expired")
	ErrIncreaseStakeVonTooLow       = common.NewBizError(301104, "Increased stake is insufficient")
	ErrDelegateVonTooLow            = common.NewBizError(301105, "Delegate deposit is insufficient")
	ErrAccountNoAllowToDelegate     = common.NewBizError(301106, "The account is not allowed to delegate")
	ErrCanNoAllowDelegate           = common.NewBizError(301107, "The candidate is not allowed to delegate")
	ErrWithdrewDelegationVonTooLow  = common.NewBizError(301108, "Withdrawal of delegation is insufficient")
	ErrDelegateNoExist              = common.NewBizError(301109, "The delegate does not exist")
	ErrWrongVonOptType              = common.NewBizError(301110, "The von operation type is incorrect")
	ErrAccountVonNoEnough           = common.NewBizError(301111, "The account balance is insufficient")
	ErrBlockNumberDisordered        = common.NewBizError(301112, "The blockNumber is inconsistent with the expected number")
	ErrDelegateVonNoEnough          = common.NewBizError(301113, "The balance of delegate is insufficient")
	ErrWrongWithdrewDelVonCalc      = common.NewBizError(301114, "The amount of delegate withdrawal is incorrect")
	ErrValidatorNoExist             = common.NewBizError(301115, "The validator does not exist")
	ErrWrongFuncParams              = common.NewBizError(301116, "The fn params is invalid")
	ErrWrongSlashType               = common.NewBizError(301117, "The slash type is illegal")
	ErrSlashVonOverflow             = common.NewBizError(301118, "The amount of slash is overflowed")
	ErrWrongSlashVonCalc            = common.NewBizError(301119, "The amount of slash for decreasing staking is incorrect")
	ErrGetVerifierList              = common.NewBizError(301200, "Retreiving verifier list failed")
	ErrGetValidatorList             = common.NewBizError(301201, "Retreiving validator list failed")
	ErrGetCandidateList             = common.NewBizError(301202, "Retreiving candidate list failed")
	ErrGetDelegateRelated           = common.NewBizError(301203, "Retreiving delegation related mapping failed")
	ErrQueryCandidateInfo           = common.NewBizError(301204, "Query candidate info failed")
	ErrQueryDelegateInfo            = common.NewBizError(301205, "Query delegate info failed")
	ErrNodeID2Addr                  = common.NewBizError(301206, "Failed to convert Node ID to address")
	ErrDelegateLockBalanceNotEnough = common.NewBizError(301207, "the user delegation lock balance is not enough for delegate")
	ErrQueryDelegationLockInfo      = common.NewBizError(301208, "Query delegation lock info failed")
)

Functions

func CanBaseKeyByAddr added in v0.7.4

func CanBaseKeyByAddr(addr common.NodeAddress) []byte

func CanBaseKeyBySuffix added in v0.7.4

func CanBaseKeyBySuffix(addr []byte) []byte

func CanMutableKeyByAddr added in v0.7.4

func CanMutableKeyByAddr(addr common.NodeAddress) []byte

func CanMutableKeyBySuffix added in v0.7.4

func CanMutableKeyBySuffix(addr []byte) []byte

func CompareDefault

func CompareDefault(removes NeedRemoveCans, left, right *Validator) int

NOTE: Sort By Default

When sorting is done by default, it is slashed and is sorted to the end.

The priorities just like that: Slashing > ProgramVersion > Shares > BlockNumber > TxIndex

Slashing: From no to yes ProgramVersion: From big to small Shares: From big to small BlockNumber: From small to big TxIndex: From small to big

Compare Left And Right 1: Left > Right 0: Left == Right -1:Left < Right

func CompareForDel

func CompareForDel(removes NeedRemoveCans, left, right *Validator) int

NOTE: These are sorted by priority that will be removed

When sorting is done by delete slashing, it is slashed and is sorted to the front.

The priorities just like that: Invalid > ProgramVersion > validaotorTerm > Shares > BlockNumber > TxIndex

What is the invalid ? That are DuplicateSign and lowRatio&invalid and lowVersion and withdrew&NotInEpochValidators

Invalid Status: From invalid to valid ProgramVersion: From small to big validaotorTerm: From big to small Shares: From small to big BlockNumber: From big to small TxIndex: From big to small

Compare Left And Right 1: Left > Right 0: Left == Right -1:Left < Right

func DecodeDelegateKey added in v0.7.6

func DecodeDelegateKey(key []byte) (delAddr common.Address, nodeId enode.IDv0, stakeBlockNumber uint64)

notice this assume key must right

func GetAccountStakeRcKey

func GetAccountStakeRcKey(addr common.Address) []byte

func GetDelegateKey

func GetDelegateKey(delAddr common.Address, nodeId enode.IDv0, stakeBlockNumber uint64) []byte

func GetDelegateKeyBySuffix

func GetDelegateKeyBySuffix(suffix []byte) []byte

func GetDelegationLockKey added in v1.3.0

func GetDelegationLockKey(delAddr common.Address) []byte

func GetEpochIndexKey

func GetEpochIndexKey() []byte

func GetEpochValArrKey

func GetEpochValArrKey(start, end uint64) []byte

func GetPPOSHASHKey

func GetPPOSHASHKey() []byte

func GetRoundAddrBoundaryKey added in v0.7.4

func GetRoundAddrBoundaryKey() []byte

func GetRoundIndexKey

func GetRoundIndexKey() []byte

func GetRoundValAddrArrKey added in v0.7.3

func GetRoundValAddrArrKey(round uint64) []byte

func GetRoundValArrKey

func GetRoundValArrKey(start, end uint64) []byte

func GetUnStakeCountKey

func GetUnStakeCountKey(epoch uint64) []byte

func GetUnStakeItemKey

func GetUnStakeItemKey(epoch, index uint64) []byte

func HistoryValidatorDBKey added in v1.4.0

func HistoryValidatorDBKey(ID common.Hash) []byte

func HistoryValidatorIDListKey added in v1.4.0

func HistoryValidatorIDListKey(blockNumber uint64) []byte

func TallyPowerKey

func TallyPowerKey(programVersion uint32, shares *big.Int, stakeBlockNum uint64, stakeTxIndex uint32, nodeID enode.IDv0) []byte

the candidate power key

Types

type Candidate

type Candidate struct {
	*CandidateBase
	*CandidateMutable
}

The Candidate info

func (*Candidate) IsEmpty added in v0.7.4

func (can *Candidate) IsEmpty() bool

func (*Candidate) IsNotEmpty added in v0.7.4

func (can *Candidate) IsNotEmpty() bool

func (*Candidate) String

func (can *Candidate) String() string

type CandidateBase added in v0.7.4

type CandidateBase struct {
	NodeId enode.IDv0
	// bls public key
	BlsPubKey bls.PublicKeyHex
	// The account used to initiate the staking
	StakingAddress common.Address
	// The account receive the block rewards and the staking rewards
	BenefitAddress common.Address
	// The tx index at the time of staking
	StakingTxIndex uint32
	// The version of the node program
	// (Store Large Verson: the 2.1.x large version is 2.1.0)
	ProgramVersion uint32
	// Block height at the time of staking
	StakingBlockNum uint64
	// Node desc
	Description
}

func (*CandidateBase) IsEmpty added in v0.7.4

func (can *CandidateBase) IsEmpty() bool

func (*CandidateBase) IsNotEmpty added in v0.7.4

func (can *CandidateBase) IsNotEmpty() bool

func (*CandidateBase) String added in v0.7.4

func (can *CandidateBase) String() string

type CandidateBaseQueue added in v0.7.4

type CandidateBaseQueue []*CandidateBase

func (CandidateBaseQueue) IsEmpty added in v0.7.4

func (queue CandidateBaseQueue) IsEmpty() bool

func (CandidateBaseQueue) IsNotEmpty added in v0.7.4

func (queue CandidateBaseQueue) IsNotEmpty() bool

type CandidateHex

type CandidateHex struct {
	NodeId               enode.IDv0
	BlsPubKey            bls.PublicKeyHex
	StakingAddress       common.Address
	BenefitAddress       common.Address
	RewardPer            uint16
	NextRewardPer        uint16
	RewardPerChangeEpoch uint32
	StakingTxIndex       uint32
	ProgramVersion       uint32
	Status               CandidateStatus
	StakingEpoch         uint32
	StakingBlockNum      uint64
	Shares               *hexutil.Big
	Released             *hexutil.Big
	ReleasedHes          *hexutil.Big
	RestrictingPlan      *hexutil.Big
	RestrictingPlanHes   *hexutil.Big
	DelegateEpoch        uint32
	DelegateTotal        *hexutil.Big
	DelegateTotalHes     *hexutil.Big
	DelegateRewardTotal  *hexutil.Big
	Description
}

Display amount field using 0x hex

func (*CandidateHex) IsEmpty added in v0.7.4

func (can *CandidateHex) IsEmpty() bool

func (*CandidateHex) IsNotEmpty added in v0.7.4

func (can *CandidateHex) IsNotEmpty() bool

func (*CandidateHex) String

func (can *CandidateHex) String() string

type CandidateHexQueue

type CandidateHexQueue []*CandidateHex

func (CandidateHexQueue) IsEmpty added in v0.7.4

func (queue CandidateHexQueue) IsEmpty() bool

func (CandidateHexQueue) IsNotEmpty added in v0.7.4

func (queue CandidateHexQueue) IsNotEmpty() bool

func (CandidateHexQueue) String added in v0.7.4

func (queue CandidateHexQueue) String() string

type CandidateMap

type CandidateMap map[enode.IDv0]*Candidate

type CandidateMutable added in v0.7.4

type CandidateMutable struct {
	// The candidate status
	// Reference `THE CANDIDATE  STATUS`
	Status CandidateStatus
	// The epoch number at staking or edit
	StakingEpoch uint32
	// All vons of staking and delegated
	Shares *big.Int
	// The staking von  is circulating for effective epoch (in effect)
	Released *big.Int
	// The staking von  is circulating for hesitant epoch (in hesitation)
	ReleasedHes *big.Int
	// The staking von  is RestrictingPlan for effective epoch (in effect)
	RestrictingPlan *big.Int
	// The staking von  is RestrictingPlan for hesitant epoch (in hesitation)
	RestrictingPlanHes *big.Int
	// The epoch number at delegate or edit
	DelegateEpoch uint32
	// Effective total delegate
	DelegateTotal *big.Int
	// hesitant total delegate
	DelegateTotalHes *big.Int
	// Delegate reward amount percent for current settlement cycle
	RewardPer uint16
	// Delegate reward amount percent for next settlement cycle
	NextRewardPer uint16
	// Number of settlement cycles when changing the commission reward percentage
	RewardPerChangeEpoch uint32

	// current epoch  total Delegate reward
	CurrentEpochDelegateReward *big.Int

	// total  Delegate reward have give
	DelegateRewardTotal *big.Int
}

func (*CandidateMutable) AddShares added in v0.7.4

func (can *CandidateMutable) AddShares(amount *big.Int)

func (*CandidateMutable) AppendStatus added in v1.0.0

func (can *CandidateMutable) AppendStatus(status CandidateStatus)

func (*CandidateMutable) CleanCurrentEpochDelegateReward added in v0.7.6

func (can *CandidateMutable) CleanCurrentEpochDelegateReward()

func (*CandidateMutable) CleanLowRatioStatus added in v0.7.4

func (can *CandidateMutable) CleanLowRatioStatus()

func (*CandidateMutable) CleanShares added in v0.7.4

func (can *CandidateMutable) CleanShares()

func (*CandidateMutable) IsDuplicateSign added in v0.7.4

func (can *CandidateMutable) IsDuplicateSign() bool

func (*CandidateMutable) IsEmpty added in v0.7.4

func (can *CandidateMutable) IsEmpty() bool

func (*CandidateMutable) IsInvalid added in v0.7.4

func (can *CandidateMutable) IsInvalid() bool

func (*CandidateMutable) IsInvalidDuplicateSign added in v0.7.4

func (can *CandidateMutable) IsInvalidDuplicateSign() bool

func (*CandidateMutable) IsInvalidLowRatio added in v0.7.4

func (can *CandidateMutable) IsInvalidLowRatio() bool

func (*CandidateMutable) IsInvalidLowRatioDel added in v0.7.4

func (can *CandidateMutable) IsInvalidLowRatioDel() bool

func (*CandidateMutable) IsInvalidLowRatioNotEnough added in v0.7.4

func (can *CandidateMutable) IsInvalidLowRatioNotEnough() bool

func (*CandidateMutable) IsInvalidNotEnough added in v0.7.4

func (can *CandidateMutable) IsInvalidNotEnough() bool

func (*CandidateMutable) IsInvalidWithdrew added in v0.7.4

func (can *CandidateMutable) IsInvalidWithdrew() bool

func (*CandidateMutable) IsLowRatio added in v0.7.4

func (can *CandidateMutable) IsLowRatio() bool

func (*CandidateMutable) IsLowRatioDel added in v0.7.4

func (can *CandidateMutable) IsLowRatioDel() bool

func (*CandidateMutable) IsLowRatioNotEnough added in v0.7.4

func (can *CandidateMutable) IsLowRatioNotEnough() bool

func (*CandidateMutable) IsNotEmpty added in v0.7.4

func (can *CandidateMutable) IsNotEmpty() bool

func (*CandidateMutable) IsNotEnough added in v0.7.4

func (can *CandidateMutable) IsNotEnough() bool

func (*CandidateMutable) IsPureInvalid added in v0.7.4

func (can *CandidateMutable) IsPureInvalid() bool

func (*CandidateMutable) IsPureLowRatio added in v0.7.4

func (can *CandidateMutable) IsPureLowRatio() bool

func (*CandidateMutable) IsPureLowRatioDel added in v0.7.4

func (can *CandidateMutable) IsPureLowRatioDel() bool

func (*CandidateMutable) IsPureNotEnough added in v0.7.4

func (can *CandidateMutable) IsPureNotEnough() bool

func (*CandidateMutable) IsPureWithdrew added in v0.7.4

func (can *CandidateMutable) IsPureWithdrew() bool

func (*CandidateMutable) IsValid added in v0.7.4

func (can *CandidateMutable) IsValid() bool

func (*CandidateMutable) IsWithdrew added in v0.7.4

func (can *CandidateMutable) IsWithdrew() bool

func (*CandidateMutable) PrepareNextEpoch added in v0.7.6

func (can *CandidateMutable) PrepareNextEpoch() bool

func (*CandidateMutable) SetStatus added in v1.0.0

func (can *CandidateMutable) SetStatus(status CandidateStatus)

func (*CandidateMutable) SetValided added in v1.0.0

func (can *CandidateMutable) SetValided()

func (*CandidateMutable) ShouldGiveDelegateReward added in v0.7.6

func (can *CandidateMutable) ShouldGiveDelegateReward() bool

func (*CandidateMutable) String added in v0.7.4

func (can *CandidateMutable) String() string

func (*CandidateMutable) SubShares added in v0.7.4

func (can *CandidateMutable) SubShares(amount *big.Int)

type CandidateQueue

type CandidateQueue []*Candidate

func (CandidateQueue) String added in v0.7.4

func (queue CandidateQueue) String() string

type CandidateStatus added in v0.7.4

type CandidateStatus uint32
const (
	/**
	######   ######   ######   ######
	#	  THE CANDIDATE  STATUS     #
	######   ######   ######   ######
	*/
	Invalided     CandidateStatus = 1 << iota // 0001: The current candidate withdraws from the staking qualification (Active OR Passive)
	LowRatio                                  // 0010: The candidate was low package ratio AND no delete
	NotEnough                                 // 0100: The current candidate's von does not meet the minimum staking threshold
	DuplicateSign                             // 1000: The Duplicate package or Duplicate sign
	LowRatioDel                               // 0001,0000: The lowRatio AND must delete
	Withdrew                                  // 0010,0000: The Active withdrew
	Valided       = 0                         // 0000: The current candidate is in force
	NotExist      = 1 << 31                   // 1000,xxxx,... : The candidate is not exist
)

func (CandidateStatus) IsDuplicateSign added in v0.7.4

func (status CandidateStatus) IsDuplicateSign() bool

func (CandidateStatus) IsInvalid added in v0.7.4

func (status CandidateStatus) IsInvalid() bool

func (CandidateStatus) IsInvalidDuplicateSign added in v0.7.4

func (status CandidateStatus) IsInvalidDuplicateSign() bool

func (CandidateStatus) IsInvalidLowRatio added in v0.7.4

func (status CandidateStatus) IsInvalidLowRatio() bool

func (CandidateStatus) IsInvalidLowRatioDel added in v0.7.4

func (status CandidateStatus) IsInvalidLowRatioDel() bool

func (CandidateStatus) IsInvalidLowRatioNotEnough added in v0.7.4

func (status CandidateStatus) IsInvalidLowRatioNotEnough() bool

func (CandidateStatus) IsInvalidNotEnough added in v0.7.4

func (status CandidateStatus) IsInvalidNotEnough() bool

func (CandidateStatus) IsInvalidWithdrew added in v0.7.4

func (status CandidateStatus) IsInvalidWithdrew() bool

func (CandidateStatus) IsLowRatio added in v0.7.4

func (status CandidateStatus) IsLowRatio() bool

func (CandidateStatus) IsLowRatioDel added in v0.7.4

func (status CandidateStatus) IsLowRatioDel() bool

func (CandidateStatus) IsLowRatioNotEnough added in v0.7.4

func (status CandidateStatus) IsLowRatioNotEnough() bool

func (CandidateStatus) IsNotEnough added in v0.7.4

func (status CandidateStatus) IsNotEnough() bool

func (CandidateStatus) IsPureInvalid added in v0.7.4

func (status CandidateStatus) IsPureInvalid() bool

func (CandidateStatus) IsPureLowRatio added in v0.7.4

func (status CandidateStatus) IsPureLowRatio() bool

func (CandidateStatus) IsPureLowRatioDel added in v0.7.4

func (status CandidateStatus) IsPureLowRatioDel() bool

func (CandidateStatus) IsPureNotEnough added in v0.7.4

func (status CandidateStatus) IsPureNotEnough() bool

func (CandidateStatus) IsPureWithdrew added in v0.7.4

func (status CandidateStatus) IsPureWithdrew() bool

func (CandidateStatus) IsValid added in v0.7.4

func (status CandidateStatus) IsValid() bool

func (CandidateStatus) IsWithdrew added in v0.7.4

func (status CandidateStatus) IsWithdrew() bool

type DelByDelegateEpoch added in v1.0.0

type DelByDelegateEpoch []*DelegationInfo

func (DelByDelegateEpoch) Len added in v1.0.0

func (d DelByDelegateEpoch) Len() int

func (DelByDelegateEpoch) Less added in v1.0.0

func (d DelByDelegateEpoch) Less(i, j int) bool

func (DelByDelegateEpoch) Swap added in v1.0.0

func (d DelByDelegateEpoch) Swap(i, j int)

type DelRelatedQueue

type DelRelatedQueue []*DelegateRelated

func (DelRelatedQueue) IsEmpty added in v0.7.4

func (queue DelRelatedQueue) IsEmpty() bool

func (DelRelatedQueue) String added in v0.7.4

func (queue DelRelatedQueue) String() string

type DelegateRelated

type DelegateRelated struct {
	Addr            common.Address
	NodeId          enode.IDv0
	StakingBlockNum uint64
}

func (*DelegateRelated) String

func (dr *DelegateRelated) String() string

type Delegation

type Delegation struct {
	// The epoch number at delegate or edit
	DelegateEpoch uint32
	// The delegate von  is circulating for effective epoch (in effect)
	Released *big.Int
	// The delegate von  is circulating for hesitant epoch (in hesitation)
	ReleasedHes *big.Int
	// The delegate von  is RestrictingPlan for effective epoch (in effect)
	RestrictingPlan *big.Int
	// The delegate von  is RestrictingPlan for hesitant epoch (in hesitation)
	RestrictingPlanHes *big.Int
	// Cumulative delegate income (Waiting for withdrawal)
	CumulativeIncome *big.Int

	// 处于犹豫期的委托金,源自锁定期
	LockReleasedHes        *big.Int
	LockRestrictingPlanHes *big.Int
}

the Delegate information

func NewDelegation added in v1.0.0

func NewDelegation() *Delegation

func (*Delegation) CleanCumulativeIncome added in v0.7.6

func (del *Delegation) CleanCumulativeIncome(epoch uint32)

func (*Delegation) IsEmpty added in v0.7.4

func (del *Delegation) IsEmpty() bool

func (*Delegation) String

func (del *Delegation) String() string

func (*Delegation) TotalHes added in v1.3.0

func (del *Delegation) TotalHes() *big.Int

type DelegationEx

type DelegationEx struct {
	Addr            common.Address
	NodeId          enode.IDv0
	StakingBlockNum uint64
	DelegationHex
}

func (*DelegationEx) IsEmpty added in v0.7.4

func (dex *DelegationEx) IsEmpty() bool

func (*DelegationEx) String

func (dex *DelegationEx) String() string

func (*DelegationEx) V1 added in v1.3.0

func (dex *DelegationEx) V1() *DelegationExV1

type DelegationExV1 added in v1.3.0

type DelegationExV1 struct {
	Addr            common.Address
	NodeId          enode.IDv0
	StakingBlockNum uint64
	DelegationHexV1
}

type DelegationForStorage added in v1.3.0

type DelegationForStorage Delegation

func (*DelegationForStorage) DecodeRLP added in v1.3.0

func (r *DelegationForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads both consensus and implementation fields of a Delegation from an RLP stream.

type DelegationHex

type DelegationHex struct {
	// The epoch number at delegate or edit
	DelegateEpoch uint32
	// The delegate von  is circulating for effective epoch (in effect)
	Released *hexutil.Big
	// The delegate von  is circulating for hesitant epoch (in hesitation)
	ReleasedHes *hexutil.Big
	// The delegate von  is RestrictingPlan for effective epoch (in effect)
	RestrictingPlan *hexutil.Big
	// The delegate von  is RestrictingPlan for hesitant epoch (in hesitation)
	RestrictingPlanHes *hexutil.Big
	// Cumulative delegate income (Waiting for withdrawal)
	CumulativeIncome *hexutil.Big

	LockReleasedHes        *hexutil.Big
	LockRestrictingPlanHes *hexutil.Big
}

func (*DelegationHex) String

func (delHex *DelegationHex) String() string

type DelegationHexV1 added in v1.3.0

type DelegationHexV1 struct {
	// The epoch number at delegate or edit
	DelegateEpoch uint32
	// The delegate von  is circulating for effective epoch (in effect)
	Released *hexutil.Big
	// The delegate von  is circulating for hesitant epoch (in hesitation)
	ReleasedHes *hexutil.Big
	// The delegate von  is RestrictingPlan for effective epoch (in effect)
	RestrictingPlan *hexutil.Big
	// The delegate von  is RestrictingPlan for hesitant epoch (in hesitation)
	RestrictingPlanHes *hexutil.Big
	// Cumulative delegate income (Waiting for withdrawal)
	CumulativeIncome *hexutil.Big
}

type DelegationInfo added in v0.7.6

type DelegationInfo struct {
	NodeID           enode.IDv0
	StakeBlockNumber uint64
	Delegation       *Delegation
}

type DelegationLock added in v1.3.0

type DelegationLock struct {
	// 锁定期
	Locks []*DelegationLockPeriod

	// 解锁期
	Released        *big.Int
	RestrictingPlan *big.Int
	// contains filtered or unexported fields
}

func NewDelegationLock added in v1.3.0

func NewDelegationLock() *DelegationLock

func (*DelegationLock) AddLock added in v1.3.0

func (d *DelegationLock) AddLock(lockEpoch uint32, released, restrictingPlan *big.Int)

func (*DelegationLock) AdvanceLockedFunds added in v1.3.0

func (d *DelegationLock) AdvanceLockedFunds(amount *big.Int) (*big.Int, *big.Int, error)

AdvanceLockedFunds 使用锁定期的委托金

func (*DelegationLock) Change added in v1.3.0

func (d *DelegationLock) Change() bool

func (*DelegationLock) ToHex added in v1.3.0

func (d *DelegationLock) ToHex() *DelegationLockHex

type DelegationLockHex added in v1.3.0

type DelegationLockHex struct {
	// 锁定期
	Locks []*DelegationLockPeriodHex
	//处于解锁期的委托金
	Released *hexutil.Big
	//处于解锁期的委托金
	RestrictingPlan *hexutil.Big
}

type DelegationLockPeriod added in v1.3.0

type DelegationLockPeriod struct {
	// 锁定截止周期
	Epoch uint32
	//处于锁定期的委托金,解锁后释放到用户余额
	Released *big.Int
	//处于锁定期的委托金,解锁后释放到用户锁仓账户
	RestrictingPlan *big.Int
}

func (*DelegationLockPeriod) String added in v1.3.0

func (d *DelegationLockPeriod) String() string

func (*DelegationLockPeriod) ToHex added in v1.3.0

type DelegationLockPeriodHex added in v1.3.0

type DelegationLockPeriodHex struct {
	// 锁定截止周期
	Epoch uint32
	//处于锁定期的委托金,解锁后释放到用户余额
	Released *hexutil.Big
	//处于锁定期的委托金,解锁后释放到用户锁仓账户
	RestrictingPlan *hexutil.Big
}

type Description

type Description struct {
	// External Id for the third party to pull the node description (with length limit)
	ExternalId string
	// The Candidate Node's Name  (with a length limit)
	NodeName string
	// The third-party home page of the node (with a length limit)
	Website string
	// Description of the node (with a length limit)
	Details string
}

func (*Description) CheckLength

func (desc *Description) CheckLength() error

type HistoryValidator added in v1.4.0

type HistoryValidator struct {
	NodeId    enode.IDv0
	BlsPubKey bls.PublicKeyHex
}

For historical node records. Store historical node information and participate in hash calculation.

func (*HistoryValidator) Decode added in v1.4.0

func (hv *HistoryValidator) Decode(enVal []byte) error

func (*HistoryValidator) Encode added in v1.4.0

func (hv *HistoryValidator) Encode() ([]byte, error)

func (*HistoryValidator) ID added in v1.4.0

func (hv *HistoryValidator) ID() common.Hash

type HistoryValidatorEx added in v1.4.0

type HistoryValidatorEx struct {
	Address   common.NodeAddress
	NodeId    enode.IDv0
	BlsPubKey bls.PublicKeyHex
}

Structure returned to the external caller.

func (*HistoryValidatorEx) String added in v1.4.0

func (h *HistoryValidatorEx) String() string

type HistoryValidatorIDList added in v1.4.0

type HistoryValidatorIDList []common.Hash

func (HistoryValidatorIDList) Decode added in v1.4.0

func (hvil HistoryValidatorIDList) Decode(enVal []byte) error

func (HistoryValidatorIDList) Encode added in v1.4.0

func (hvil HistoryValidatorIDList) Encode() ([]byte, error)

type HistoryValidatorList added in v1.4.0

type HistoryValidatorList []*HistoryValidator

func (HistoryValidatorList) Hash added in v1.4.0

func (hvl HistoryValidatorList) Hash() (common.Hash, error)

Calculating the Hash of the Consensus Wheel Node List.

type NeedRemoveCans

type NeedRemoveCans map[enode.IDv0]*Candidate

type SlashNodeItem added in v0.7.3

type SlashNodeItem struct {
	// the nodeId will be slashed
	NodeId enode.IDv0
	// the amount of von with slashed
	Amount *big.Int
	// slash type
	SlashType CandidateStatus
	// the benefit adrr who will receive the slash amount of von
	BenefitAddr common.Address
}

An item that exists for slash

func (*SlashNodeItem) String added in v0.7.4

func (s *SlashNodeItem) String() string

type SlashQueue added in v0.7.3

type SlashQueue []*SlashNodeItem

func (SlashQueue) String added in v0.7.4

func (queue SlashQueue) String() string

type StakingDB

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

func NewStakingDB

func NewStakingDB() *StakingDB

func NewStakingDBWithDB added in v0.7.6

func NewStakingDBWithDB(db snapshotdb.DB) *StakingDB

func (*StakingDB) AddAccountStakeRc

func (db *StakingDB) AddAccountStakeRc(blockHash common.Hash, addr common.Address) error

func (*StakingDB) AddUnStakeItemStore

func (db *StakingDB) AddUnStakeItemStore(blockHash common.Hash, epoch uint64, canAddr common.NodeAddress, stakeBlockNumber uint64, recovery bool) error

func (*StakingDB) Del added in v1.0.0

func (db *StakingDB) Del(blockHash common.Hash, key []byte) error

func (*StakingDB) DelCanBaseStore added in v0.7.4

func (db *StakingDB) DelCanBaseStore(blockHash common.Hash, addr common.NodeAddress) error

func (*StakingDB) DelCanMutableStore added in v0.7.4

func (db *StakingDB) DelCanMutableStore(blockHash common.Hash, addr common.NodeAddress) error

func (*StakingDB) DelCanPowerStore

func (db *StakingDB) DelCanPowerStore(blockHash common.Hash, can *Candidate) error

func (*StakingDB) DelCandidateStore

func (db *StakingDB) DelCandidateStore(blockHash common.Hash, addr common.NodeAddress) error

func (*StakingDB) DelDelegateStore

func (db *StakingDB) DelDelegateStore(blockHash common.Hash, delAddr common.Address, nodeId enode.IDv0,
	stakeBlockNumber uint64) error

func (*StakingDB) DelEpochValListByBlockHash

func (db *StakingDB) DelEpochValListByBlockHash(blockHash common.Hash, start, end uint64) error

func (*StakingDB) DelRoundValListByBlockHash

func (db *StakingDB) DelRoundValListByBlockHash(blockHash common.Hash, start, end uint64) error

func (*StakingDB) DelRoundValidatorAddrs added in v0.7.3

func (db *StakingDB) DelRoundValidatorAddrs(blockHash common.Hash, key []byte) error

func (*StakingDB) DelUnStakeCountStore

func (db *StakingDB) DelUnStakeCountStore(blockHash common.Hash, epoch uint64) error

func (*StakingDB) DelUnStakeItemStore

func (db *StakingDB) DelUnStakeItemStore(blockHash common.Hash, epoch, index uint64) error

func (*StakingDB) GetCanBaseStore added in v0.7.4

func (db *StakingDB) GetCanBaseStore(blockHash common.Hash, addr common.NodeAddress) (*CandidateBase, error)

func (*StakingDB) GetCanBaseStoreByIrr added in v0.7.4

func (db *StakingDB) GetCanBaseStoreByIrr(addr common.NodeAddress) (*CandidateBase, error)

func (*StakingDB) GetCanBaseStoreByIrrWithSuffix added in v0.7.4

func (db *StakingDB) GetCanBaseStoreByIrrWithSuffix(suffix []byte) (*CandidateBase, error)

func (*StakingDB) GetCanBaseStoreWithSuffix added in v0.7.4

func (db *StakingDB) GetCanBaseStoreWithSuffix(blockHash common.Hash, suffix []byte) (*CandidateBase, error)

func (*StakingDB) GetCanMutableStore added in v0.7.4

func (db *StakingDB) GetCanMutableStore(blockHash common.Hash, addr common.NodeAddress) (*CandidateMutable, error)

func (*StakingDB) GetCanMutableStoreByIrr added in v0.7.4

func (db *StakingDB) GetCanMutableStoreByIrr(addr common.NodeAddress) (*CandidateMutable, error)

func (*StakingDB) GetCanMutableStoreByIrrWithSuffix added in v0.7.4

func (db *StakingDB) GetCanMutableStoreByIrrWithSuffix(suffix []byte) (*CandidateMutable, error)

func (*StakingDB) GetCanMutableStoreWithSuffix added in v0.7.4

func (db *StakingDB) GetCanMutableStoreWithSuffix(blockHash common.Hash, suffix []byte) (*CandidateMutable, error)

func (*StakingDB) GetCandidateStore

func (db *StakingDB) GetCandidateStore(blockHash common.Hash, addr common.NodeAddress) (*Candidate, error)

func (*StakingDB) GetCandidateStoreByIrr

func (db *StakingDB) GetCandidateStoreByIrr(addr common.NodeAddress) (*Candidate, error)

func (*StakingDB) GetCandidateStoreByIrrWithSuffix

func (db *StakingDB) GetCandidateStoreByIrrWithSuffix(suffix []byte) (*Candidate, error)

func (*StakingDB) GetCandidateStoreWithSuffix

func (db *StakingDB) GetCandidateStoreWithSuffix(blockHash common.Hash, suffix []byte) (*Candidate, error)

func (*StakingDB) GetDB added in v1.0.0

func (db *StakingDB) GetDB() snapshotdb.DB

func (*StakingDB) GetDelegateStore

func (db *StakingDB) GetDelegateStore(blockHash common.Hash, delAddr common.Address, nodeId enode.IDv0, stakeBlockNumber uint64) (*Delegation, error)

func (*StakingDB) GetDelegatesInfo added in v0.7.6

func (db *StakingDB) GetDelegatesInfo(blockHash common.Hash, delAddr common.Address) ([]*DelegationInfo, error)

func (*StakingDB) GetDelegationLock added in v1.3.0

func (db *StakingDB) GetDelegationLock(blockHash common.Hash, delAddr common.Address, currentEpoch uint32) (*DelegationLock, error)

func (*StakingDB) GetEpochValIndexByBlockHash

func (db *StakingDB) GetEpochValIndexByBlockHash(blockHash common.Hash) (ValArrIndexQueue, error)

func (*StakingDB) GetEpochValIndexByIrr

func (db *StakingDB) GetEpochValIndexByIrr() (ValArrIndexQueue, error)

func (*StakingDB) GetEpochValListByBlockHash

func (db *StakingDB) GetEpochValListByBlockHash(blockHash common.Hash, start, end uint64) (ValidatorQueue, error)

func (*StakingDB) GetEpochValListByIrr

func (db *StakingDB) GetEpochValListByIrr(start, end uint64) (ValidatorQueue, error)

func (*StakingDB) GetLastKVHash

func (db *StakingDB) GetLastKVHash(blockHash common.Hash) []byte

func (*StakingDB) GetRoundAddrBoundary added in v0.7.4

func (db *StakingDB) GetRoundAddrBoundary(blockHash common.Hash) (uint64, error)

func (*StakingDB) GetRoundValIndexByBlockHash

func (db *StakingDB) GetRoundValIndexByBlockHash(blockHash common.Hash) (ValArrIndexQueue, error)

func (*StakingDB) GetRoundValIndexByIrr

func (db *StakingDB) GetRoundValIndexByIrr() (ValArrIndexQueue, error)

func (*StakingDB) GetRoundValListByBlockHash

func (db *StakingDB) GetRoundValListByBlockHash(blockHash common.Hash, start, end uint64) (ValidatorQueue, error)

func (*StakingDB) GetRoundValListByIrr

func (db *StakingDB) GetRoundValListByIrr(start, end uint64) (ValidatorQueue, error)

func (*StakingDB) GetUnStakeCountStore

func (db *StakingDB) GetUnStakeCountStore(blockHash common.Hash, epoch uint64) (uint64, error)

func (*StakingDB) GetUnStakeItemStore

func (db *StakingDB) GetUnStakeItemStore(blockHash common.Hash, epoch, index uint64) (*UnStakeItem, error)

func (*StakingDB) HasAccountStakeRc

func (db *StakingDB) HasAccountStakeRc(blockHash common.Hash, addr common.Address) (bool, error)

func (*StakingDB) IteratorCandidatePowerByBlockHash

func (db *StakingDB) IteratorCandidatePowerByBlockHash(blockHash common.Hash, ranges int) iterator.Iterator

func (*StakingDB) IteratorDelegateByBlockHashWithAddr

func (db *StakingDB) IteratorDelegateByBlockHashWithAddr(blockHash common.Hash, addr common.Address, ranges int) iterator.Iterator

func (*StakingDB) LoadRoundValidatorAddrs added in v0.7.3

func (db *StakingDB) LoadRoundValidatorAddrs(blockHash common.Hash, key []byte) ([]common.Address, error)

func (*StakingDB) PutDelegationLock added in v1.3.0

func (db *StakingDB) PutDelegationLock(blockHash common.Hash, delAddr common.Address, infos *DelegationLock) error

func (*StakingDB) SetCanBaseStore added in v0.7.4

func (db *StakingDB) SetCanBaseStore(blockHash common.Hash, addr common.NodeAddress, can *CandidateBase) error

func (*StakingDB) SetCanMutableStore added in v0.7.4

func (db *StakingDB) SetCanMutableStore(blockHash common.Hash, addr common.NodeAddress, can *CandidateMutable) error

func (*StakingDB) SetCanPowerStore

func (db *StakingDB) SetCanPowerStore(blockHash common.Hash, addr common.NodeAddress, can *Candidate) error

func (*StakingDB) SetCandidateStore

func (db *StakingDB) SetCandidateStore(blockHash common.Hash, addr common.NodeAddress, can *Candidate) error

func (*StakingDB) SetDelegateStore

func (db *StakingDB) SetDelegateStore(blockHash common.Hash, delAddr common.Address, nodeId enode.IDv0,
	stakeBlockNumber uint64, del *Delegation, isEinstein bool) error

func (*StakingDB) SetEpochValIndex

func (db *StakingDB) SetEpochValIndex(blockHash common.Hash, indexArr ValArrIndexQueue) error

func (*StakingDB) SetEpochValList

func (db *StakingDB) SetEpochValList(blockHash common.Hash, start, end uint64, valArr ValidatorQueue) error

func (*StakingDB) SetRoundAddrBoundary added in v0.7.4

func (db *StakingDB) SetRoundAddrBoundary(blockHash common.Hash, round uint64) error

func (*StakingDB) SetRoundValIndex

func (db *StakingDB) SetRoundValIndex(blockHash common.Hash, indexArr ValArrIndexQueue) error

func (*StakingDB) SetRoundValList

func (db *StakingDB) SetRoundValList(blockHash common.Hash, start, end uint64, valArr ValidatorQueue) error

func (*StakingDB) StoreRoundValidatorAddrs added in v0.7.3

func (db *StakingDB) StoreRoundValidatorAddrs(blockHash common.Hash, key []byte, arry []common.NodeAddress) error

func (*StakingDB) SubAccountStakeRc

func (db *StakingDB) SubAccountStakeRc(blockHash common.Hash, addr common.Address) error

type UnStakeItem

type UnStakeItem struct {
	// this is the nodeAddress
	NodeAddress     common.NodeAddress
	StakingBlockNum uint64
	// Return to normal staking state
	Recovery bool
}

type ValArrIndex

type ValArrIndex struct {
	Start uint64
	End   uint64
}

func (*ValArrIndex) String added in v0.7.4

func (vindex *ValArrIndex) String() string

type ValArrIndexQueue

type ValArrIndexQueue []*ValArrIndex

func (ValArrIndexQueue) ConstantAppend

func (queue ValArrIndexQueue) ConstantAppend(index *ValArrIndex, size int) (*ValArrIndex, ValArrIndexQueue)

func (ValArrIndexQueue) String added in v0.7.4

func (queue ValArrIndexQueue) String() string

type Validator

type Validator struct {
	ProgramVersion  uint32
	StakingTxIndex  uint32
	ValidatorTerm   uint32 // Validator's term in the consensus round
	StakingBlockNum uint64
	NodeAddress     common.NodeAddress
	NodeId          enode.IDv0
	BlsPubKey       bls.PublicKeyHex
	Shares          *big.Int
}

the Validator info They are Simplified Candidate They are consensus nodes and Epoch nodes snapshot

type Validator struct {
	NodeAddress common.Address
	NodeId      discover.NodeID
	// bls public key
	BlsPubKey bls.PublicKeyHex
	// The weight snapshot
	// NOTE:
	// converted from the weight snapshot of Candidate, they array order is:
	//
	// programVersion, candidate.shares, stakingBlocknum, stakingTxindex
	//
	// They origin type is: uint32, *big.Int, uint64, uint32
	StakingWeight [SWeightItem]string
	// Validator's term in the consensus round
	ValidatorTerm uint32
}

func (*Validator) String

func (val *Validator) String() string

type ValidatorArray

type ValidatorArray struct {
	// the round start blockNumber or epoch start blockNumber
	Start uint64
	// the round end blockNumber or epoch blockNumber
	End uint64
	// the round validators or epoch validators
	Arr ValidatorQueue
}

some consensus round validators or current epoch validators

func (ValidatorArray) String added in v0.7.4

func (v ValidatorArray) String() string

type ValidatorEx

type ValidatorEx struct {
	//NodeAddress common.Address
	NodeId enode.IDv0
	// bls public key
	BlsPubKey bls.PublicKeyHex
	// The account used to initiate the staking
	StakingAddress common.Address
	// The account receive the block rewards and the staking rewards
	BenefitAddress common.Address
	// Delegate reward amount percent for current settlement cycle
	RewardPer uint16
	// Delegate reward amount percent for next settlement cycle
	NextRewardPer uint16
	// Number of settlement cycles when changing the commission reward percentage
	RewardPerChangeEpoch uint32
	// The tx index at the time of staking
	StakingTxIndex uint32
	// The version of the node process
	ProgramVersion uint32
	// Block height at the time of staking
	StakingBlockNum uint64
	// All vons of staking and delegated
	//Shares *big.Int
	Shares *hexutil.Big
	// Node desc
	Description
	// this is the term of validator in consensus round
	// [0, N]
	ValidatorTerm uint32
	// Effective total delegate
	DelegateTotal *hexutil.Big

	DelegateRewardTotal *hexutil.Big
}

func (*ValidatorEx) String

func (vex *ValidatorEx) String() string

type ValidatorExQueue

type ValidatorExQueue []*ValidatorEx

func (ValidatorExQueue) IsEmpty added in v0.7.4

func (queue ValidatorExQueue) IsEmpty() bool

func (ValidatorExQueue) IsNotEmpty added in v0.7.4

func (queue ValidatorExQueue) IsNotEmpty() bool

func (ValidatorExQueue) String added in v0.7.4

func (queue ValidatorExQueue) String() string

type ValidatorQueue

type ValidatorQueue []*Validator

func (ValidatorQueue) IsEmpty added in v0.7.4

func (queue ValidatorQueue) IsEmpty() bool

func (ValidatorQueue) IsNotEmpty added in v0.7.4

func (queue ValidatorQueue) IsNotEmpty() bool

func (ValidatorQueue) String added in v0.7.4

func (queue ValidatorQueue) String() string

func (ValidatorQueue) ValidatorSort

func (arr ValidatorQueue) ValidatorSort(removes NeedRemoveCans,
	compare func(slashs NeedRemoveCans, c, can *Validator) int)

Jump to

Keyboard shortcuts

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