Documentation ¶
Overview ¶
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php
Index ¶
- Constants
- Variables
- func BackUpdata(top *mc.TopologyGraph, mapp map[uint16]common.Address, native AllNative) uint16
- func CalcGradeDependAddr(addr common.Address, native AllNative) int
- func FindAddress(addr common.Address, addrList []common.Address) bool
- func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
- func GetList_MEP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
- func GetList_VIP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
- func KInTop(aim uint16, topoG *mc.TopologyGraph) bool
- func MakeElectNode(address common.Address, Pos int, Stock int, VIPLevel common.VIPRoleType, ...) mc.ElectNodeInfo
- func MakeMinerAns(chosed []Strallyint, seqnum uint64) *mc.MasterMinerReElectionRsp
- func MakeValidatoeTopGenAns(seqnum uint64, master []Strallyint, backup []Strallyint, candiate []Strallyint) *mc.MasterValidatorReElectionRsq
- func PrimarylistUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo)
- func Sample1NodesInValNodes_Common(probnormalized []Pnormalized, rand01 float64) (common.Address, bool)
- func Sample1NodesInValNodes_VIP(probnormalized []Pnormalized, rand01 float64) (common.Address, bool)
- func ToPoUpdate(allNative AllNative, topoG *mc.TopologyGraph) []mc.Alternative
- type AllNative
- type BlockProduceProc
- type Electoion
- func (vip *Electoion) DisPlayNode()
- func (vip *Electoion) FilterBlockSlashList()
- func (vip *Electoion) GenSuperNode(superThreshold int64) ([]Strallyint, []Node)
- func (vip *Electoion) GetAvailableNodeNum() int
- func (vip *Electoion) GetIndex(addr common.Address) (int, bool)
- func (vip *Electoion) GetLastNode() []Node
- func (vip *Electoion) GetMinSuperNodeAmount() (bool, uint64)
- func (vip *Electoion) GetNodeByAccount(address common.Address) (int, bool)
- func (vip *Electoion) GetNodeByLevel(level common.VIPRoleType) []Node
- func (vip *Electoion) GetNodeIndexByLevel(level common.VIPRoleType) []int
- func (vip *Electoion) GetUsableNode() []Node
- func (vip *Electoion) GetVipStock(addr common.Address) int
- func (vip *Electoion) GetWeight(role common.RoleType) []Pnormalized
- func (vip *Electoion) ProcessBlackNode()
- func (vip *Electoion) ProcessWhiteNode()
- func (vip *Electoion) SetBlockBlackList(list mc.BlockProduceSlashBlackList)
- func (vip *Electoion) SetChosed(node []Strallyint)
- func (vip *Electoion) SuperNodeStockProc(randSuperNodeStock map[common.Address]int, stockExp float64)
- type Node
- type Pnormalized
- type QuantRatio
- type RatioList
- type SelfNodeInfo
- type SortNodeList
- type SortStrallyint
- type Strallyint
Constants ¶
const ( ModuleLogName = "选举基础模块" MaxSample = 1000 //配置参数,采样最多发生1000次,是一个离P+M较远的值 PowerWeightMaxSmple = 1000 J = 0 //基金会验证节点个数tps_weight DefaultStock = 1 )
const ( DefaultNodeConfig = 0 MaxVipEleLevelNum = 2 DefaultRatio = 1000 DefaultRatioDenominator = 1000 DefaultMinerDeposit = 10000 DefaultValidatorDeposit = 100000 )
const ( ValidatorElectPlug_Direct = "Direct" ValidatorElectPlug_Order = "Order" )
const (
DefaultMinerStock = 1
)
Variables ¶
var ( DefaultTps = uint64(1000) DefalutValidatorElectPlug = ValidatorElectPlug_Order //选举所要用到的插件 1.直接选11+5 2.依次选11+5 DefaultVIPStock = []int{3, 2, 1} //默认股权能否配载vip列表里(创世文件) DefaultQuantificationRatio = QuantRatio{ Multi_Online: 0, Multi_Tps: 0, Multi_Deposit: 0.0, Add_Online: 0, Add_Deposit: 1.0, } DefaultTpsRatio = []RatioList{ RatioList{ MinNum: 16000, Ratio: 5.0, }, RatioList{ MinNum: 8000, Ratio: 4.0, }, RatioList{ MinNum: 4000, Ratio: 3.0, }, RatioList{ MinNum: 2000, Ratio: 2.0, }, RatioList{ MinNum: 1000, Ratio: 1.0, }, RatioList{ MinNum: 0, Ratio: 0.0, }, } DefaultOnlineTimeRatio = []RatioList{ RatioList{ MinNum: 512, Ratio: 4.0, }, RatioList{ MinNum: 256, Ratio: 2.0, }, RatioList{ MinNum: 128, Ratio: 1.0, }, RatioList{ MinNum: 64, Ratio: 0.5, }, RatioList{ MinNum: 0, Ratio: 0.25, }, } DefaultMinerDepositRatio = []RatioList{ RatioList{ MinNum: 50000, Ratio: 5.0, }, RatioList{ MinNum: 40000, Ratio: 4.0, }, RatioList{ MinNum: 30000, Ratio: 3.0, }, RatioList{ MinNum: 20000, Ratio: 2.0, }, RatioList{ MinNum: 0, Ratio: 0.0, }, } DefaultValidatorDepositRatio = []RatioList{ RatioList{ MinNum: 800000, Ratio: 4.0, }, RatioList{ MinNum: 600000, Ratio: 3.0, }, RatioList{ MinNum: 400000, Ratio: 2.0, }, RatioList{ MinNum: 200000, Ratio: 1.0, }, RatioList{ MinNum: 0, Ratio: 0.0, }, } )
Functions ¶
func BackUpdata ¶
func GetList_Common ¶
func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
func GetList_MEP ¶
func GetList_MEP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
func GetList_VIP ¶
func GetList_VIP(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)
func MakeElectNode ¶
func MakeElectNode(address common.Address, Pos int, Stock int, VIPLevel common.VIPRoleType, Type common.RoleType) mc.ElectNodeInfo
func MakeMinerAns ¶
func MakeMinerAns(chosed []Strallyint, seqnum uint64) *mc.MasterMinerReElectionRsp
func MakeValidatoeTopGenAns ¶
func MakeValidatoeTopGenAns(seqnum uint64, master []Strallyint, backup []Strallyint, candiate []Strallyint) *mc.MasterValidatorReElectionRsq
func PrimarylistUpdate ¶
func PrimarylistUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo)
func Sample1NodesInValNodes_Common ¶
func Sample1NodesInValNodes_Common(probnormalized []Pnormalized, rand01 float64) (common.Address, bool)
func Sample1NodesInValNodes_VIP ¶
func Sample1NodesInValNodes_VIP(probnormalized []Pnormalized, rand01 float64) (common.Address, bool)
func ToPoUpdate ¶
func ToPoUpdate(allNative AllNative, topoG *mc.TopologyGraph) []mc.Alternative
Types ¶
type AllNative ¶
type AllNative struct { Master []mc.ElectNodeInfo //验证者主节点 BackUp []mc.ElectNodeInfo //验证者备份 Candidate []mc.ElectNodeInfo //验证者候选 MasterQ []common.Address //第一梯队候选 BackUpQ []common.Address //第二梯队候选 CandidateQ []common.Address //第三梯队候选 ElectInfo *mc.ElectConfigInfo }
type BlockProduceProc ¶
type BlockProduceProc struct { List []mc.UserBlockProduceSlash // contains filtered or unexported fields }
func NewBlockProduceProc ¶
func NewBlockProduceProc(blackList mc.BlockProduceSlashBlackList) *BlockProduceProc
func (*BlockProduceProc) DecrementCount ¶
func (s *BlockProduceProc) DecrementCount(address common.Address)
func (*BlockProduceProc) IsBlackList ¶
func (s *BlockProduceProc) IsBlackList(address common.Address) (int, bool)
type Electoion ¶
type Electoion struct { SeqNum uint64 RandSeed *mt19937.RandUniform VipLevelCfg []mc.VIPConfig NodeList []Node EleCfg mc.ElectConfigInfo_All ChosedNum int NeedNum int HasChosedNode [][]Strallyint MapMoney map[common.Address]uint64 BlockProduceSlashBlackList mc.BlockProduceSlashBlackList BlockBlackProc *BlockProduceProc }
func NewElelection ¶
func NewMEPElection ¶
func (*Electoion) DisPlayNode ¶
func (vip *Electoion) DisPlayNode()
func (*Electoion) FilterBlockSlashList ¶
func (vip *Electoion) FilterBlockSlashList()
func (*Electoion) GenSuperNode ¶
func (vip *Electoion) GenSuperNode(superThreshold int64) ([]Strallyint, []Node)
func (*Electoion) GetAvailableNodeNum ¶
func (*Electoion) GetLastNode ¶
func (*Electoion) GetMinSuperNodeAmount ¶
func (*Electoion) GetNodeByAccount ¶
func (*Electoion) GetNodeByLevel ¶
func (vip *Electoion) GetNodeByLevel(level common.VIPRoleType) []Node
func (*Electoion) GetNodeIndexByLevel ¶
func (vip *Electoion) GetNodeIndexByLevel(level common.VIPRoleType) []int
func (*Electoion) GetUsableNode ¶
func (*Electoion) ProcessBlackNode ¶
func (vip *Electoion) ProcessBlackNode()
func (*Electoion) ProcessWhiteNode ¶
func (vip *Electoion) ProcessWhiteNode()
func (*Electoion) SetBlockBlackList ¶
func (vip *Electoion) SetBlockBlackList(list mc.BlockProduceSlashBlackList)
func (*Electoion) SetChosed ¶
func (vip *Electoion) SetChosed(node []Strallyint)
type Node ¶
type Node struct { Address common.Address SignAddress common.Address Deposit *big.Int WithdrawH *big.Int OnlineTime *big.Int Ratio uint16 Usable bool // contains filtered or unexported fields }
func (*Node) SetDepositInfo ¶
func (node *Node) SetDepositInfo(depsit vm.DepositDetail)
type Pnormalized ¶
func CalcValueEW ¶
func CalcValueEW(nodes []Node, stockExp float64) []Pnormalized
func Normalize_Common ¶
func Normalize_Common(probVal []Pnormalized) []Pnormalized
func Normalize_VIP ¶
func Normalize_VIP(probVal []Pnormalized) []Pnormalized
type QuantRatio ¶
type SelfNodeInfo ¶
func (*SelfNodeInfo) DepositStake ¶
func (self *SelfNodeInfo) DepositStake(roles common.RoleType) float64
func (*SelfNodeInfo) OnlineTimeStake ¶
func (self *SelfNodeInfo) OnlineTimeStake() float64
func (*SelfNodeInfo) TPSPowerStake ¶
func (self *SelfNodeInfo) TPSPowerStake() float64
type SortNodeList ¶
type SortNodeList []Node
func (SortNodeList) Len ¶
func (self SortNodeList) Len() int
func (SortNodeList) Less ¶
func (self SortNodeList) Less(i, j int) bool
func (SortNodeList) Swap ¶
func (self SortNodeList) Swap(i, j int)
type SortStrallyint ¶
type SortStrallyint []Strallyint
func (SortStrallyint) Len ¶
func (self SortStrallyint) Len() int
func (SortStrallyint) Less ¶
func (self SortStrallyint) Less(i, j int) bool
func (SortStrallyint) Swap ¶
func (self SortStrallyint) Swap(i, j int)
type Strallyint ¶
type Strallyint struct { Value int Addr common.Address VIPLevel common.VIPRoleType }
func RandSampleFilterBlackList ¶
func RandSampleFilterBlackList(randNodeValue []Pnormalized, superNodeValue []Pnormalized, needNum int, rand *mt19937.RandUniform, blackList *BlockProduceProc) ([]Strallyint, map[common.Address]int)