Documentation
¶
Index ¶
- Constants
- func DeepCopy(dst, src interface{}) error
- type AccountMap
- type AccountMapList
- type CurrentRoundValData
- type EthAccounts
- type MinerRewardStrategy
- type NextRoundValData
- type PosItem
- type PosTable
- func (posTable *PosTable) RemovePosItem(account common.Address) (bool, error)
- func (posTable *PosTable) SelectItemByHeightValue(random int) PosItem
- func (posTable *PosTable) SelectItemBySeedValue(vrf []byte, len int) PosItem
- func (posTable *PosTable) SetThreShold(threShold *big.Int)
- func (posTable *PosTable) UpsertPosItem(signer common.Address, balance *big.Int, beneficiary common.Address, ...) (bool, error)
- type Strategy
- func (strategy *Strategy) CollectTx(tx *ethTypes.Transaction)
- func (strategy *Strategy) GetUpdatedValidators() []*abciTypes.Validator
- func (s *Strategy) Receiver() common.Address
- func (strategy *Strategy) SetAccountMapList(accountMapList *AccountMapList)
- func (strategy *Strategy) SetValidators(validators []*abciTypes.Validator)
- type ValListItem
- type ValSortlist
- type ValidatorsStrategy
Constants ¶
const PosTableMaxSize = 2000
const ThresholdUnit = 1000
it means the lowest balance must equal or larger than the 1/1000 of totalBalance
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountMap ¶
type AccountMap struct {
Signer common.Address `json:"signer"`
SignerBalance *big.Int `json:"signerBalance"`
BeneficiaryBonus *big.Int `json:"beneficiaryBonus"`
Beneficiary common.Address `json:"beneficiary"`
BlsKeyString string `json:"blsKeyString"`
}
AccountMap is an initial accountMap between tendermitn address and go-ethereum-address.
type AccountMapList ¶
type AccountMapList struct {
MapList map[string]*AccountMap `json:"accountmaplist"`
FilePath string `json:"filePath"`
// contains filtered or unexported fields
}
AccountMapList defines the initial list of AccountMap.
func AccountMapFromFile ¶
func AccountMapFromFile(AccountMapFile string) (*AccountMapList, error)
AccountMapFromJSON reads JSON data from a file and unmarshalls it into a AccountMapList.
func AccountMapFromJSON ¶
func AccountMapFromJSON(jsonBlob []byte) (*AccountMapList, error)
AccountMapFromJSON unmarshalls JSON data into a AccountMapList.
func (*AccountMapList) GenAccountMapList ¶
func (am *AccountMapList) GenAccountMapList(filePath string) *AccountMapList
GenFilePV generates a new validator with randomly generated private key and sets the filePath, but does not call Save().
type CurrentRoundValData ¶
type CurrentRoundValData struct {
AccountMapList *AccountMapList `json:"accountMapList"`
//This map was used when some validator was removed when initial at initChain(i.e dont have enough money)
// and didnt existed in the accountMapList
// we should remember it for balance bonus and then clear it
AccMapInitial *AccountMapList `json:"accMapInitial"`
// will be changed by addValidatorTx and removeValidatorTx.
PosTable *PosTable `json:"posTable"`
// current candidate Validators , will changed every 200 height,will be changed by addValidatorTx and removeValidatorTx
CurrCandidateValidators []*abciTypes.Validator `json:"currCandidateValidators"`
// Initial validators , only use for once
InitialValidators []*abciTypes.Validator `json:"initialValidators"`
// validators of currentBlock, will use to set votePower to 0 ,then remove from tendermint validatorSet
// will be select by postable.
// CurrentValidators is the true validators except commmittee validator when height != 1
// if height =1 ,CurrentValidator = nil
CurrentValidators []*abciTypes.Validator `json:"currentValidators"`
// current validator weight represent the weight of random select.
// will used to accumulateReward for next height
CurrentValidatorWeight []int64 `json:"currentValidatorWeight"`
TotalBalance *big.Int `json:"totalBalance"`
ProposerAddress string `json:"proposerAddress"`
}
type EthAccounts ¶
type EthAccounts struct {
EthAccounts []string `json:"ethAccounts"`
EthBalances []*big.Int `json:"ethBalances"`
EthBeneficiarys []string `json:"ethBeneficiarys"`
}
func EthAccountsFromJSON ¶
func EthAccountsFromJSON(jsonBlob []byte) (*EthAccounts, error)
EthAccountsFromJSON unmarshalls JSON data into a eth accounts.
func GetInitialEthAccountFromFile ¶
func GetInitialEthAccountFromFile(EthAccountsPath string) (*EthAccounts, error)
GetInitialEthAccountFromFile reads JSON data from a file and unmarshalls it into a initial eth accounts.
type MinerRewardStrategy ¶
MinerRewardStrategy is a mining strategy
type NextRoundValData ¶
type NextRoundValData struct {
//we should deepcopy evert 200 height
//first deepcopy:copy at height 1 from CurrentRoundValData to NextRoundValData
//height/200 ==0:c from NextRoundValData to CurrentRoundValData `json:"-"`
NextRoundPosTable *PosTable `json:"nextRoundPosTable"`
NextRoundCandidateValidators []*abciTypes.Validator `json:"nextRoundCandidateValidators"`
NextAccountMapList *AccountMapList `json:"nextAccountMapList"`
}
type PosTable ¶
type PosTable struct {
PosItemMap map[common.Address]*PosItem `json:"posItemMap"` //This isnt called by foreign struct except rpc
PosArray []common.Address `json:"posArray"` // All posItem,it will contained the same item
PosArraySize int `json:"posArraySize"` // real size of posArray
Threshold *big.Int `json:"threshold"` // threshold value of PosTable
ChangedFlagThisBlock bool `json:"changedFlagThisBlock"`
PosNodeSortList *ValSortlist `json:"-"`
// contains filtered or unexported fields
}
func NewPosTable ¶
func (*PosTable) RemovePosItem ¶
func (*PosTable) SelectItemByHeightValue ¶
func (*PosTable) SelectItemBySeedValue ¶
func (*PosTable) SetThreShold ¶
type Strategy ¶
type Strategy struct {
MinerRewardStrategy
ValidatorsStrategy
//need to be persisted
FirstInitial bool
//needn't to be persisted
BlsSelectStrategy bool
// reused,need persistence
CurrRoundValData CurrentRoundValData
//reused,need persistence
NextRoundValData NextRoundValData
// contains filtered or unexported fields
}
Strategy encompasses all available strategies
func NewStrategy ¶
func (*Strategy) CollectTx ¶
func (strategy *Strategy) CollectTx(tx *ethTypes.Transaction)
CollectTx collects the rewards for a transaction
func (*Strategy) GetUpdatedValidators ¶
GetUpdatedValidators returns the current validators
func (*Strategy) SetAccountMapList ¶
func (strategy *Strategy) SetAccountMapList(accountMapList *AccountMapList)
GetUpdatedValidators returns the current validators
func (*Strategy) SetValidators ¶
SetValidators updates the current validators
type ValListItem ¶
type ValSortlist ¶
func NewValSortlist ¶
func NewValSortlist() *ValSortlist
func (*ValSortlist) GetTopValTmAddress ¶
func (vallist *ValSortlist) GetTopValTmAddress() map[string]bool
func (*ValSortlist) RemoveVal ¶
func (vallist *ValSortlist) RemoveVal(valListItem *ValListItem)
func (*ValSortlist) UpsertVal ¶
func (valSortlist *ValSortlist) UpsertVal(valListItem *ValListItem, existFlag bool)
type ValidatorsStrategy ¶
type ValidatorsStrategy interface {
SetValidators(validators []*abciTypes.Validator)
CollectTx(tx *ethTypes.Transaction)
GetUpdatedValidators() []*abciTypes.Validator
}
ValidatorsStrategy is a validator strategy