election

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2018 The MATRIX Authors as well as Copyright 2014-2017 The go-ethereum Authors This file is consisted of the MATRIX library and part of the go-ethereum library.

The MATRIX-ethereum library is free software: you can redistribute it and/or modify it under the terms of the MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject tothe following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright 2018 The MATRIX Authors as well as Copyright 2014-2017 The go-ethereum Authors This file is consisted of the MATRIX library and part of the go-ethereum library.

The MATRIX-ethereum library is free software: you can redistribute it and/or modify it under the terms of the MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject tothe following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(probVal []Stf) []pnormalized

func Sample1NodesInValNodes

func Sample1NodesInValNodes(probnormalized []pnormalized, rand01 float64) string

func WriteWithFileWrite

func WriteWithFileWrite(name, content string)

Types

type CandidateInfo

type CandidateInfo struct {
	Address common.Address
	TPS     uint64
	UpTime  uint64
	Deposit uint64
}

type ElectEventType

type ElectEventType string

type ElectMMSub

type ElectMMSub struct {
	MasterMinerReElectionReqMsgCH  chan *mc.MasterMinerReElectionReqMsg
	MasterMinerReElectionReqMsgSub event.Subscription
}

type ElectMVSub

type ElectMVSub struct {
	MasterValidatorReElectionReqMsgCH  chan *mc.MasterValidatorReElectionReqMsg
	MasterValidatorReElectionReqMsgSub event.Subscription
}

type ElectionResultInfo

type ElectionResultInfo struct {
	Address common.Address
	Stake   uint64
}

type Elector

type Elector struct {
	EleMMSub ElectMMSub
	EleMVSub ElectMVSub
	EleMMRs  chan *mc.MasterMinerReElectionRsp
	EleMVRs  chan *mc.MasterValidatorReElectionRsq
	Engine   func(probVal []Stf, seed int64, M int, P int, J int) ([]Strallyint, []Strallyint, []Strallyint) //Engine    func(probVal []Stf, seed int64) ([]Strallyint, []Strallyint, []Strallyint) //func(probVal map[string]float32, seed int64) ([]Strallyint, []Strallyint, []Strallyint)

	MaxSample int //配置参数,采样最多发生1000次,是一个离P+M较远的值
	J         int //基金会验证节点个数tps_weight
	M         int //验证主节点个数
	P         int //备份主节点个数
	N         int //矿工主节点个数
	// contains filtered or unexported fields
}

func NewEle

func NewEle() *Elector

func (*Elector) ChoiceEngine

func (Ele *Elector) ChoiceEngine(flag int)

func (*Elector) CommbineFundNodesAndPricipal

func (Ele *Elector) CommbineFundNodesAndPricipal(probVal []Stf, probFund []Stf, PricipalValNodes []Strallyint, ratiodnlimit float64, ratiouplimit float64) []Strallyint

func (*Elector) EleServer

func (Ele *Elector) EleServer()

func (*Elector) Listen

func (Ele *Elector) Listen()

func (*Elector) MinerNodesSelected

func (Ele *Elector) MinerNodesSelected(probVal []Stf, seed int64, Ms int) ([]Strallyint, []Strallyint)

func (*Elector) Post

func (Ele *Elector) Post()

func (*Elector) PrimarylistUpdate

func (Ele *Elector) PrimarylistUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo)

func (*Elector) SampleMPlusPNodes

func (Ele *Elector) SampleMPlusPNodes(probnormalized []pnormalized, seed int64) ([]Strallyint, []Strallyint, []Strallyint)

做异常判断

func (*Elector) SampleMinerNodes

func (Ele *Elector) SampleMinerNodes(probnormalized []pnormalized, seed int64, Ms int) ([]Strallyint, []Strallyint)

func (*Elector) ToPoUpdate

func (Ele *Elector) ToPoUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, nettopo mc.TopologyGraph, offline []common.Address) []mc.Alternative

func (*Elector) ValNodesSelected

func (Ele *Elector) ValNodesSelected(probVal []Stf, seed int64, M int, P int, J int) ([]Strallyint, []Strallyint, []Strallyint)

func (Ele *Elector) ValNodesSelected(probVal []Stf, seed int64) ([]Strallyint, []Strallyint, []Strallyint) {

type Mynode

type Mynode struct {
	Nodeid string
	Tps    int
	Stk    float64
	Uptime int
}

type Self

type Self struct {
	Coef_tps float64
	Coef_stk float64
	// contains filtered or unexported fields
}

func (*Self) Last_Time

func (self *Self) Last_Time() float64

func (*Self) TPS_POWER

func (self *Self) TPS_POWER() float64

type Stf

type Stf struct {
	Str  string
	Flot float64
}

func CalcAllValueFunction

func CalcAllValueFunction(nodelist []vm.DepositDetail) []Stf

type Strallyint

type Strallyint struct {
	Value  int
	Nodeid string
}

func CalcRemainingNodesVotes

func CalcRemainingNodesVotes(RemainingProbNormalizedNodes []Strallyint) []Strallyint

Directories

Path Synopsis
ManElec100

Jump to

Keyboard shortcuts

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