support

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 10 Imported by: 33

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

Index

Constants

View Source
const (
	ModuleLogName       = "选举基础模块"
	MaxSample           = 1000 //配置参数,采样最多发生1000次,是一个离P+M较远的值
	PowerWeightMaxSmple = 1000
	J                   = 0 //基金会验证节点个数tps_weight
	DefaultStock        = 1
)
View Source
const (
	DefaultNodeConfig       = 0
	MaxVipEleLevelNum       = 2
	DefaultRatio            = 1000
	DefaultRatioDenominator = 1000
	DefaultMinerDeposit     = 10000
	DefaultValidatorDeposit = 100000
)
View Source
const (
	ValidatorElectPlug_Direct = "Direct"
	ValidatorElectPlug_Order  = "Order"
)
View Source
const (
	DefaultMinerStock = 1
)

Variables

View Source
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 BackUpdata(top *mc.TopologyGraph, mapp map[uint16]common.Address, native AllNative) uint16

func CalcGradeDependAddr

func CalcGradeDependAddr(addr common.Address, native AllNative) int

func FindAddress

func FindAddress(addr common.Address, addrList []common.Address) bool

func GetList_Common

func GetList_Common(probnormalized []Pnormalized, needNum int, rand *mt19937.RandUniform) ([]Strallyint, []Pnormalized)

func GetList_MEP added in v1.1.3

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 KInTop

func KInTop(aim uint16, topoG *mc.TopologyGraph) bool

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
}

func DelIndex

func DelIndex(native AllNative, flag int) AllNative

func GetNodeFromBuff

func GetNodeFromBuff(native AllNative) (AllNative, common.Address)

type BlockProduceProc added in v1.1.4

type BlockProduceProc struct {
	List []mc.UserBlockProduceSlash
	// contains filtered or unexported fields
}

func NewBlockProduceProc added in v1.1.4

func NewBlockProduceProc(blackList mc.BlockProduceSlashBlackList) *BlockProduceProc

func (*BlockProduceProc) DecrementCount added in v1.1.4

func (s *BlockProduceProc) DecrementCount(address common.Address)

func (*BlockProduceProc) IsBlackList added in v1.1.4

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 NewElelection(VipLevelCfg []mc.VIPConfig, vm []vm.DepositDetail, EleCfg mc.ElectConfigInfo_All, randseed *big.Int, seqNum uint64, types common.RoleType) *Electoion

func NewMEPElection added in v1.1.3

func NewMEPElection(VipLevelCfg []mc.VIPConfig, vm []vm.DepositDetail, EleCfg mc.ElectConfigInfo_All, randseed *big.Int, seqNum uint64, types common.RoleType) *Electoion

func (*Electoion) DisPlayNode

func (vip *Electoion) DisPlayNode()

func (*Electoion) FilterBlockSlashList added in v1.1.4

func (vip *Electoion) FilterBlockSlashList()

func (*Electoion) GenSuperNode added in v1.1.4

func (vip *Electoion) GenSuperNode(superThreshold int64) ([]Strallyint, []Node)

func (*Electoion) GetAvailableNodeNum

func (vip *Electoion) GetAvailableNodeNum() int

func (*Electoion) GetIndex

func (vip *Electoion) GetIndex(addr common.Address) (int, bool)

func (*Electoion) GetLastNode

func (vip *Electoion) GetLastNode() []Node

func (*Electoion) GetMinSuperNodeAmount added in v1.1.4

func (vip *Electoion) GetMinSuperNodeAmount() (bool, uint64)

func (*Electoion) GetNodeByAccount

func (vip *Electoion) GetNodeByAccount(address common.Address) (int, bool)

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 added in v1.1.4

func (vip *Electoion) GetUsableNode() []Node

func (*Electoion) GetVipStock

func (vip *Electoion) GetVipStock(addr common.Address) int

func (*Electoion) GetWeight

func (vip *Electoion) GetWeight(role common.RoleType) []Pnormalized

func (*Electoion) ProcessBlackNode

func (vip *Electoion) ProcessBlackNode()

func (*Electoion) ProcessWhiteNode

func (vip *Electoion) ProcessWhiteNode()

func (*Electoion) SetBlockBlackList added in v1.1.4

func (vip *Electoion) SetBlockBlackList(list mc.BlockProduceSlashBlackList)

func (*Electoion) SetChosed

func (vip *Electoion) SetChosed(node []Strallyint)

func (*Electoion) SuperNodeStockProc added in v1.1.4

func (vip *Electoion) SuperNodeStockProc(randSuperNodeStock map[common.Address]int, stockExp float64)

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 Knuth_Fisher_Yates_Algorithm

func Knuth_Fisher_Yates_Algorithm(nodeList []Node, randSeed *big.Int) []Node

func (*Node) SetDepositInfo

func (node *Node) SetDepositInfo(depsit vm.DepositDetail)

func (*Node) SetIndex

func (node *Node) SetIndex(index int)

func (*Node) SetUsable

func (node *Node) SetUsable(status bool)

func (*Node) SetVipLevelInfo

func (node *Node) SetVipLevelInfo(VipLevelCfg []mc.VIPConfig) uint64

type Pnormalized

type Pnormalized struct {
	Value float64
	Addr  common.Address
}

func CalcValue

func CalcValue(nodes []Node, role common.RoleType) []Pnormalized

func CalcValueEW added in v1.1.4

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 QuantRatio struct {
	Multi_Online  float64
	Multi_Tps     float64
	Multi_Deposit float64
	Add_Online    float64
	Add_Deposit   float64
}

type RatioList

type RatioList struct {
	MinNum uint64
	Ratio  float64
}

type SelfNodeInfo

type SelfNodeInfo struct {
	Address common.Address
	Stk     *big.Int
	Uptime  uint64
	Tps     uint64
}

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 added in v1.1.4

func RandSampleFilterBlackList(randNodeValue []Pnormalized, superNodeValue []Pnormalized, needNum int, rand *mt19937.RandUniform, blackList *BlockProduceProc) ([]Strallyint, map[common.Address]int)

Jump to

Keyboard shortcuts

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