staking

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 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"
	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, "Wrong bls public key")
	ErrWrongBlsPubKeyProof       = common.NewBizError(301001, "Wrong bls public key proof")
	ErrDescriptionLen            = common.NewBizError(301002, "The Description length is wrong")
	ErrWrongProgramVersionSign   = common.NewBizError(301003, "The program version sign is wrong")
	ErrProgramVersionTooLow      = common.NewBizError(301004, "The program version of the relates node's is too low")
	ErrDeclVsFialedCreateCan     = common.NewBizError(301005, "DeclareVersion is failed on create staking")
	ErrNoSameStakingAddr         = common.NewBizError(301006, "The address must be the same as initiated staking")
	ErrStakeVonTooLow            = common.NewBizError(301100, "Staking deposit too low")
	ErrCanAlreadyExist           = common.NewBizError(301101, "This candidate is already exist")
	ErrCanNoExist                = common.NewBizError(301102, "This candidate is not exist")
	ErrCanStatusInvalid          = common.NewBizError(301103, "This candidate status was invalided")
	ErrIncreaseStakeVonTooLow    = common.NewBizError(301104, "IncreaseStake von is too low")
	ErrDelegateVonTooLow         = common.NewBizError(301105, "Delegate deposit too low")
	ErrAccountNoAllowToDelegate  = common.NewBizError(301106, "The account is not allowed to be used for delegating")
	ErrCanNoAllowDelegate        = common.NewBizError(301107, "The candidate does not accept the delegation")
	ErrWithdrewDelegateVonTooLow = common.NewBizError(301108, "Withdrew delegation von is too low")
	ErrDelegateNoExist           = common.NewBizError(301109, "This delegation is not exist")
	ErrWrongVonOptType           = common.NewBizError(301110, "The von operation type is wrong")
	ErrAccountVonNoEnough        = common.NewBizError(301111, "The von of account is not enough")
	ErrBlockNumberDisordered     = common.NewBizError(301112, "The blockNumber is disordered")
	ErrDelegateVonNoEnough       = common.NewBizError(301113, "The von of delegation is not enough")
	ErrWrongWithdrewDelVonCalc   = common.NewBizError(301114, "Withdrew delegation von calculation is wrong")
	ErrValidatorNoExist          = common.NewBizError(301115, "The validator is not exist")
	ErrWrongFuncParams           = common.NewBizError(301116, "The fn params is wrong")
	ErrWrongSlashType            = common.NewBizError(301117, "The slashing type is wrong")
	ErrSlashVonOverflow          = common.NewBizError(301118, "Slashing amount is overflow")
	ErrWrongSlashVonCalc         = common.NewBizError(301119, "Slashing candidate von calculate is wrong")
	ErrGetVerifierList           = common.NewBizError(301200, "Getting verifierList is failed")
	ErrGetValidatorList          = common.NewBizError(301201, "Getting validatorList is failed")
	ErrGetCandidateList          = common.NewBizError(301202, "Getting candidateList is failed")
	ErrGetDelegateRelated        = common.NewBizError(301203, "Getting related of delegate is failed")
	ErrQueryCandidateInfo        = common.NewBizError(301204, "Query candidate info failed")
	ErrQueryDelegateInfo         = common.NewBizError(301205, "Query delegate info failed")
)

Functions

func CanBaseKeyByAddr added in v0.7.4

func CanBaseKeyByAddr(addr common.Address) []byte

func CanBaseKeyByNodeId added in v0.7.4

func CanBaseKeyByNodeId(nodeId discover.NodeID) ([]byte, error)

CanBase ...

func CanBaseKeyByPubKey added in v0.7.4

func CanBaseKeyByPubKey(p ecdsa.PublicKey) []byte

func CanBaseKeyBySuffix added in v0.7.4

func CanBaseKeyBySuffix(addr []byte) []byte

func CanMutableKeyByAddr added in v0.7.4

func CanMutableKeyByAddr(addr common.Address) []byte

func CanMutableKeyByNodeId added in v0.7.4

func CanMutableKeyByNodeId(nodeId discover.NodeID) ([]byte, error)

CanMutable ...

func CanMutableKeyByPubKey added in v0.7.4

func CanMutableKeyByPubKey(p ecdsa.PublicKey) []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 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 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 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 TallyPowerKey

func TallyPowerKey(shares *big.Int, stakeBlockNum uint64, stakeTxIndex, programVersion uint32) []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 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 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             discover.NodeID
	BlsPubKey          bls.PublicKeyHex
	StakingAddress     common.Address
	BenefitAddress     common.Address
	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
	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[discover.NodeID]*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
}

func (*CandidateMutable) AddShares added in v0.7.4

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

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

type DelRelatedQueue []*DelegateRelated

func (DelRelatedQueue) IsEmpty added in v0.7.4

func (queue DelRelatedQueue) IsEmpty() bool

func (DelRelatedQueue) IsNotEmpty added in v0.7.4

func (queue DelRelatedQueue) IsNotEmpty() bool

func (DelRelatedQueue) String added in v0.7.4

func (queue DelRelatedQueue) String() string

type DelegateRelated

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

func (*DelegateRelated) IsEmpty added in v0.7.4

func (dr *DelegateRelated) IsEmpty() bool

func (*DelegateRelated) IsNotEmpty added in v0.7.4

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
}

the Delegate information

func (*Delegation) IsEmpty added in v0.7.4

func (del *Delegation) IsEmpty() bool

func (*Delegation) IsNotEmpty added in v0.7.4

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 added in v0.7.4

func (dex *DelegationEx) IsEmpty() bool

func (*DelegationEx) IsNotEmpty added in v0.7.4

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
}

func (*DelegationHex) IsEmpty added in v0.7.4

func (del *DelegationHex) IsEmpty() bool

func (*DelegationHex) IsNotEmpty added in v0.7.4

func (del *DelegationHex) IsNotEmpty() bool

func (*DelegationHex) String

func (delHex *DelegationHex) String() string

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 added in v0.7.3

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 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 (*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.Address, stakeBlockNumber uint64) error

func (*StakingDB) DelCanBaseStore added in v0.7.4

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

func (*StakingDB) DelCanMutableStore added in v0.7.4

func (db *StakingDB) DelCanMutableStore(blockHash common.Hash, addr common.Address) 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.Address) 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 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.Address) (*CandidateBase, error)

func (*StakingDB) GetCanBaseStoreByIrr added in v0.7.4

func (db *StakingDB) GetCanBaseStoreByIrr(addr common.Address) (*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.Address) (*CandidateMutable, error)

func (*StakingDB) GetCanMutableStoreByIrr added in v0.7.4

func (db *StakingDB) GetCanMutableStoreByIrr(addr common.Address) (*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.Address) (*Candidate, error)

func (*StakingDB) GetCandidateStoreByIrr

func (db *StakingDB) GetCandidateStoreByIrr(addr common.Address) (*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) 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) 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) SetCanBaseStore added in v0.7.4

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

func (*StakingDB) SetCanMutableStore added in v0.7.4

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

func (*StakingDB) SetCanPowerStore

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

func (*StakingDB) SetCandidateStore

func (db *StakingDB) SetCandidateStore(blockHash common.Hash, addr common.Address, 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 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.Address) 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.Address
	StakingBlockNum uint64
}

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.Address
	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 added in v0.7.4

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
	// 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
}

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