staking

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CanBasePrefixStr           = "CanBase"
	CanMutablePrefixStr        = "CanMut"
	CanPowerPrefixStr          = "Power"
	UnStakeCountKeyStr         = "UnStakeCount"
	UnStakeItemKeyStr          = "UnStakeItem"
	DelegatePrefixStr          = "Del"
	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)
	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")
)

Functions

func CanBaseKeyByAddr

func CanBaseKeyByAddr(addr common.NodeAddress) []byte

func CanBaseKeyBySuffix

func CanBaseKeyBySuffix(addr []byte) []byte

func CanMutableKeyByAddr

func CanMutableKeyByAddr(addr common.NodeAddress) []byte

func CanMutableKeyBySuffix

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 CompareForStore

func CompareForStore(_ NeedRemoveCans, left, right *Validator) int

NOTE: Sort when doing storage

The priorities just like that: (No shares) ProgramVersion > validaotorTerm > BlockNumber > TxIndex

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

func DecodeDelegateKey

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

notice this assume key must right

func GetAccountStakeRcKey

func GetAccountStakeRcKey(addr common.Address) []byte

func GetDelegateKey

func GetDelegateKey(delAddr common.Address, nodeId discover.NodeID, stakeBlockNumber uint64) []byte

func GetDelegateKeyBySuffix

func GetDelegateKeyBySuffix(suffix []byte) []byte

func GetEpochIndexKey

func GetEpochIndexKey() []byte

func GetEpochValArrKey

func GetEpochValArrKey(start, end uint64) []byte

func GetPPOSHASHKey

func GetPPOSHASHKey() []byte

func GetRoundAddrBoundaryKey

func GetRoundAddrBoundaryKey() []byte

func GetRoundIndexKey

func GetRoundIndexKey() []byte

func GetRoundValAddrArrKey

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 TallyPowerKey

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

the candidate power key

Types

type Candidate

type Candidate struct {
	*CandidateBase
	*CandidateMutable
}

The Candidate info

func (*Candidate) IsEmpty

func (can *Candidate) IsEmpty() bool

func (*Candidate) IsNotEmpty

func (can *Candidate) IsNotEmpty() bool

func (*Candidate) String

func (can *Candidate) String() string

type CandidateBase

type CandidateBase struct {
	NodeId discover.NodeID
	// 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

func (can *CandidateBase) IsEmpty() bool

func (*CandidateBase) IsNotEmpty

func (can *CandidateBase) IsNotEmpty() bool

func (*CandidateBase) String

func (can *CandidateBase) String() string

type CandidateBaseQueue

type CandidateBaseQueue []*CandidateBase

func (CandidateBaseQueue) IsEmpty

func (queue CandidateBaseQueue) IsEmpty() bool

func (CandidateBaseQueue) IsNotEmpty

func (queue CandidateBaseQueue) IsNotEmpty() bool

type CandidateHex

type CandidateHex struct {
	NodeId               discover.NodeID
	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

func (can *CandidateHex) IsEmpty() bool

func (*CandidateHex) IsNotEmpty

func (can *CandidateHex) IsNotEmpty() bool

func (*CandidateHex) String

func (can *CandidateHex) String() string

type CandidateHexQueue

type CandidateHexQueue []*CandidateHex

func (CandidateHexQueue) IsEmpty

func (queue CandidateHexQueue) IsEmpty() bool

func (CandidateHexQueue) IsNotEmpty

func (queue CandidateHexQueue) IsNotEmpty() bool

func (CandidateHexQueue) String

func (queue CandidateHexQueue) String() string

type CandidateMap

type CandidateMap map[discover.NodeID]*Candidate

type CandidateMutable

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

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

func (*CandidateMutable) AppendStatus

func (can *CandidateMutable) AppendStatus(status CandidateStatus)

func (*CandidateMutable) CleanCurrentEpochDelegateReward

func (can *CandidateMutable) CleanCurrentEpochDelegateReward()

func (*CandidateMutable) CleanLowRatioStatus

func (can *CandidateMutable) CleanLowRatioStatus()

func (*CandidateMutable) CleanShares

func (can *CandidateMutable) CleanShares()

func (*CandidateMutable) IsDuplicateSign

func (can *CandidateMutable) IsDuplicateSign() bool

func (*CandidateMutable) IsEmpty

func (can *CandidateMutable) IsEmpty() bool

func (*CandidateMutable) IsInvalid

func (can *CandidateMutable) IsInvalid() bool

func (*CandidateMutable) IsInvalidDuplicateSign

func (can *CandidateMutable) IsInvalidDuplicateSign() bool

func (*CandidateMutable) IsInvalidLowRatio

func (can *CandidateMutable) IsInvalidLowRatio() bool

func (*CandidateMutable) IsInvalidLowRatioDel

func (can *CandidateMutable) IsInvalidLowRatioDel() bool

func (*CandidateMutable) IsInvalidLowRatioNotEnough

func (can *CandidateMutable) IsInvalidLowRatioNotEnough() bool

func (*CandidateMutable) IsInvalidNotEnough

func (can *CandidateMutable) IsInvalidNotEnough() bool

func (*CandidateMutable) IsInvalidWithdrew

func (can *CandidateMutable) IsInvalidWithdrew() bool

func (*CandidateMutable) IsLowRatio

func (can *CandidateMutable) IsLowRatio() bool

func (*CandidateMutable) IsLowRatioDel

func (can *CandidateMutable) IsLowRatioDel() bool

func (*CandidateMutable) IsLowRatioNotEnough

func (can *CandidateMutable) IsLowRatioNotEnough() bool

func (*CandidateMutable) IsNotEmpty

func (can *CandidateMutable) IsNotEmpty() bool

func (*CandidateMutable) IsNotEnough

func (can *CandidateMutable) IsNotEnough() bool

func (*CandidateMutable) IsPureInvalid

func (can *CandidateMutable) IsPureInvalid() bool

func (*CandidateMutable) IsPureLowRatio

func (can *CandidateMutable) IsPureLowRatio() bool

func (*CandidateMutable) IsPureLowRatioDel

func (can *CandidateMutable) IsPureLowRatioDel() bool

func (*CandidateMutable) IsPureNotEnough

func (can *CandidateMutable) IsPureNotEnough() bool

func (*CandidateMutable) IsPureWithdrew

func (can *CandidateMutable) IsPureWithdrew() bool

func (*CandidateMutable) IsValid

func (can *CandidateMutable) IsValid() bool

func (*CandidateMutable) IsWithdrew

func (can *CandidateMutable) IsWithdrew() bool

func (*CandidateMutable) PrepareNextEpoch

func (can *CandidateMutable) PrepareNextEpoch() bool

func (*CandidateMutable) SetStatus

func (can *CandidateMutable) SetStatus(status CandidateStatus)

func (*CandidateMutable) SetValided

func (can *CandidateMutable) SetValided()

func (*CandidateMutable) ShouldGiveDelegateReward

func (can *CandidateMutable) ShouldGiveDelegateReward() bool

func (*CandidateMutable) String

func (can *CandidateMutable) String() string

func (*CandidateMutable) SubShares

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

type CandidateQueue

type CandidateQueue []*Candidate

func (CandidateQueue) String

func (queue CandidateQueue) String() string

type CandidateStatus

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

func (status CandidateStatus) IsDuplicateSign() bool

func (CandidateStatus) IsInvalid

func (status CandidateStatus) IsInvalid() bool

func (CandidateStatus) IsInvalidDuplicateSign

func (status CandidateStatus) IsInvalidDuplicateSign() bool

func (CandidateStatus) IsInvalidLowRatio

func (status CandidateStatus) IsInvalidLowRatio() bool

func (CandidateStatus) IsInvalidLowRatioDel

func (status CandidateStatus) IsInvalidLowRatioDel() bool

func (CandidateStatus) IsInvalidLowRatioNotEnough

func (status CandidateStatus) IsInvalidLowRatioNotEnough() bool

func (CandidateStatus) IsInvalidNotEnough

func (status CandidateStatus) IsInvalidNotEnough() bool

func (CandidateStatus) IsInvalidWithdrew

func (status CandidateStatus) IsInvalidWithdrew() bool

func (CandidateStatus) IsLowRatio

func (status CandidateStatus) IsLowRatio() bool

func (CandidateStatus) IsLowRatioDel

func (status CandidateStatus) IsLowRatioDel() bool

func (CandidateStatus) IsLowRatioNotEnough

func (status CandidateStatus) IsLowRatioNotEnough() bool

func (CandidateStatus) IsNotEnough

func (status CandidateStatus) IsNotEnough() bool

func (CandidateStatus) IsPureInvalid

func (status CandidateStatus) IsPureInvalid() bool

func (CandidateStatus) IsPureLowRatio

func (status CandidateStatus) IsPureLowRatio() bool

func (CandidateStatus) IsPureLowRatioDel

func (status CandidateStatus) IsPureLowRatioDel() bool

func (CandidateStatus) IsPureNotEnough

func (status CandidateStatus) IsPureNotEnough() bool

func (CandidateStatus) IsPureWithdrew

func (status CandidateStatus) IsPureWithdrew() bool

func (CandidateStatus) IsValid

func (status CandidateStatus) IsValid() bool

func (CandidateStatus) IsWithdrew

func (status CandidateStatus) IsWithdrew() bool

type DelByDelegateEpoch

type DelByDelegateEpoch []*DelegationInfo

func (DelByDelegateEpoch) Len

func (d DelByDelegateEpoch) Len() int

func (DelByDelegateEpoch) Less

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

func (DelByDelegateEpoch) Swap

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

type DelRelatedQueue

type DelRelatedQueue []*DelegateRelated

func (DelRelatedQueue) IsEmpty

func (queue DelRelatedQueue) IsEmpty() bool

func (DelRelatedQueue) IsNotEmpty

func (queue DelRelatedQueue) IsNotEmpty() bool

func (DelRelatedQueue) String

func (queue DelRelatedQueue) String() string

type DelegateRelated

type DelegateRelated struct {
	Addr            common.Address
	NodeId          discover.NodeID
	StakingBlockNum uint64
}

func (*DelegateRelated) IsEmpty

func (dr *DelegateRelated) IsEmpty() bool

func (*DelegateRelated) IsNotEmpty

func (dr *DelegateRelated) IsNotEmpty() bool

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
}

the Delegate information

func NewDelegation

func NewDelegation() *Delegation

func (*Delegation) CleanCumulativeIncome

func (del *Delegation) CleanCumulativeIncome(epoch uint32)

func (*Delegation) IsEmpty

func (del *Delegation) IsEmpty() bool

func (*Delegation) IsNotEmpty

func (del *Delegation) IsNotEmpty() bool

func (*Delegation) String

func (del *Delegation) String() string

type DelegationEx

type DelegationEx struct {
	Addr            common.Address
	NodeId          discover.NodeID
	StakingBlockNum uint64
	DelegationHex
}

func (*DelegationEx) IsEmpty

func (dex *DelegationEx) IsEmpty() bool

func (*DelegationEx) IsNotEmpty

func (dex *DelegationEx) IsNotEmpty() bool

func (*DelegationEx) String

func (dex *DelegationEx) String() string

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
}

func (*DelegationHex) IsEmpty

func (del *DelegationHex) IsEmpty() bool

func (*DelegationHex) IsNotEmpty

func (del *DelegationHex) IsNotEmpty() bool

func (*DelegationHex) String

func (delHex *DelegationHex) String() string

type DelegationInfo

type DelegationInfo struct {
	NodeID           discover.NodeID
	StakeBlockNumber uint64
	Delegation       *Delegation
}

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 NeedRemoveCans

type NeedRemoveCans map[discover.NodeID]*Candidate

type SlashNodeItem

type SlashNodeItem struct {
	// the nodeId will be slashed
	NodeId discover.NodeID
	// 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

func (s *SlashNodeItem) String() string

type SlashQueue

type SlashQueue []*SlashNodeItem

func (SlashQueue) String

func (queue SlashQueue) String() string

type StakingDB

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

func NewStakingDB

func NewStakingDB() *StakingDB

func NewStakingDBWithDB

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

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

func (*StakingDB) DelCanBaseStore

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

func (*StakingDB) DelCanMutableStore

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 discover.NodeID,
	stakeBlockNumber uint64) error

func (*StakingDB) DelDelegateStoreBySuffix

func (db *StakingDB) DelDelegateStoreBySuffix(blockHash common.Hash, suffix []byte) 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

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

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

func (*StakingDB) GetCanBaseStoreByIrr

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

func (*StakingDB) GetCanBaseStoreByIrrWithSuffix

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

func (*StakingDB) GetCanBaseStoreWithSuffix

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

func (*StakingDB) GetCanMutableStore

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

func (*StakingDB) GetCanMutableStoreByIrr

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

func (*StakingDB) GetCanMutableStoreByIrrWithSuffix

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

func (*StakingDB) GetCanMutableStoreWithSuffix

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

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

func (*StakingDB) GetDelegateStore

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

func (*StakingDB) GetDelegateStoreByIrr

func (db *StakingDB) GetDelegateStoreByIrr(delAddr common.Address, nodeId discover.NodeID, stakeBlockNumber uint64) (*Delegation, error)

func (*StakingDB) GetDelegateStoreBySuffix

func (db *StakingDB) GetDelegateStoreBySuffix(blockHash common.Hash, keySuffix []byte) (*Delegation, error)

func (*StakingDB) GetDelegatesInfo

func (db *StakingDB) GetDelegatesInfo(blockHash common.Hash, delAddr common.Address) ([]*DelegationInfo, 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

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

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

func (*StakingDB) SetCanBaseStore

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

func (*StakingDB) SetCanMutableStore

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 discover.NodeID,
	stakeBlockNumber uint64, del *Delegation) error

func (*StakingDB) SetDelegateStoreBySuffix

func (db *StakingDB) SetDelegateStoreBySuffix(blockHash common.Hash, suffix []byte, del *Delegation) 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

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

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

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

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          discover.NodeID
	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

func (v ValidatorArray) String() string

type ValidatorEx

type ValidatorEx struct {
	//NodeAddress common.Address
	NodeId discover.NodeID
	// 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

func (queue ValidatorExQueue) IsEmpty() bool

func (ValidatorExQueue) IsNotEmpty

func (queue ValidatorExQueue) IsNotEmpty() bool

func (ValidatorExQueue) String

func (queue ValidatorExQueue) String() string

type ValidatorQueue

type ValidatorQueue []*Validator

func (ValidatorQueue) IsEmpty

func (queue ValidatorQueue) IsEmpty() bool

func (ValidatorQueue) IsNotEmpty

func (queue ValidatorQueue) IsNotEmpty() bool

func (ValidatorQueue) String

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