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.
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.
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
- Variables
- func GetAllElectedByHeight(Heigh *big.Int, tp common.RoleType) ([]vm.DepositDetail, error)
- func GetCurrentTopology(height uint64, reqtypes common.RoleType) (*mc.TopologyGraph, error)
- func GetDepost() ([]vm.DepositDetail, []common.Address)
- func GetFound() []vm.DepositDetail
- func IsInArray(aimAddress common.Address, offline []common.Address) bool
- func IsMinerTopGenTiming(height uint64) bool
- func IsValidatorTopGenTiming(height uint64) bool
- func IsinFristPeriod(height uint64) bool
- func MakeElectDBKey(height uint64, role common.RoleType) string
- func MakeNativeDBKey(height uint64) string
- func NeedReadTopoFromDB(height uint64) bool
- func Test()
- type AllNative
- type Backend
- type ElectMiner
- type ElectReturnInfo
- type ElectValidator
- type ReElection
- func (self *ReElection) CalOnline(diff common.NetTopology, top *mc.TopologyGraph) ([]common.Address, []common.Address)
- func (self *ReElection) CalcbeforeSeedGen(height uint64) mc.RandomRequest
- func (self *ReElection) GetElection(height uint64) (*ElectReturnInfo, error)
- func (self *ReElection) GetHashByNum(height uint64) common.Hash
- func (self *ReElection) GetNativeFromDB(height uint64) error
- func (self *ReElection) GetNetTopologyAll(height uint64) (*ElectReturnInfo, error)
- func (self *ReElection) GetSeed(height uint64) (*big.Int, error)
- func (self *ReElection) GetTopoChange(height uint64, offline []common.Address) ([]mc.Alternative, error)
- func (self *ReElection) HandleTopGen(height uint64) error
- func (self *ReElection) NativeUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo)
- func (self *ReElection) ParsePrimaryTopNodeState(topologyChg common.NetTopology) ([]common.Address, []common.Address)
- func (self *ReElection) ParseTopNodeOffline(topologyChg common.NetTopology, prevTopology *mc.TopologyGraph) []common.Address
- func (self *ReElection) ToGenMinerTop(height uint64) error
- func (self *ReElection) ToGenValidatorTop(height uint64) error
- func (self *ReElection) ToNativeMinerStateUpdate(height uint64, allNative AllNative) (AllNative, error)
- func (self *ReElection) ToNativeValidatorStateUpdate(height uint64, allNative AllNative) (AllNative, error)
- func (self *ReElection) TopoUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, netTop mc.TopologyGraph, ...) []mc.Alternative
- func (self *ReElection) TransferToElectionStu(info *ElectReturnInfo) []common.Elect
- func (self *ReElection) TransferToNetTopologyAllStu(info *ElectReturnInfo) *common.NetTopology
- func (self *ReElection) TransferToNetTopologyChgStu(alterInfo []mc.Alternative, onlinePrimaryNods []common.Address, ...) *common.NetTopology
- type TestELECT
Constants ¶
const (
Module = "换届服务"
)
Variables ¶
var ( BroadCastInterval = common.GetBroadcastInterval() MinerTopGenTiming = common.GetReElectionInterval() - man.MinerTopologyGenerateUpTime MinerNetchangeTiming = common.GetReElectionInterval() - man.MinerNetChangeUpTime ValidatorTopGenTiming = common.GetReElectionInterval() - man.VerifyTopologyGenerateUpTime ValidatorNetChangeTiming = common.GetReElectionInterval() - man.VerifyNetChangeUpTime Time_Out_Limit = 2 * time.Second ChanSize = 10 )
Functions ¶
func GetAllElectedByHeight ¶
func GetCurrentTopology ¶
func GetFound ¶
func GetFound() []vm.DepositDetail
func IsMinerTopGenTiming ¶
func (self *ReElection) UpdateNative(height uint64, allNative AllNative) error {
allNative, err := self.ToNativeMinerStateUpdate(height, allNative) if err != nil { log.ERROR(Module, "ToNativeMinerStateUpdate miner err ", err) return nil } allNative, err = self.ToNativeValidatorStateUpdate(height, allNative) if err != nil { log.INFO(Module, "ToNativeMinerStateUpdate validator err", err) return nil } err=self.writeNativeData(height, allNative) log.INFO(Module,"更新初选列表阶段","写初选列表到数据库","高度",height,"err",err) return err
}
是不是矿工拓扑生成时间段
func IsinFristPeriod ¶
func MakeNativeDBKey ¶
func NeedReadTopoFromDB ¶
Types ¶
type AllNative ¶
type AllNative struct { MasterMiner []mc.TopologyNodeInfo //矿工主节点 BackUpMiner []mc.TopologyNodeInfo //矿工备份 MasterValidator []mc.TopologyNodeInfo //验证者主节点 BackUpValidator []mc.TopologyNodeInfo //验证者备份 CandidateValidator []mc.TopologyNodeInfo //验证者候选 }
type Backend ¶
type Backend interface { AccountManager() *accounts.Manager BlockChain() *core.BlockChain TxPool() *core.TxPool ChainDb() mandb.Database }
Backend wraps all methods required for mining.
type ElectMiner ¶
type ElectMiner struct { MasterMiner []mc.TopologyNodeInfo BackUpMiner []mc.TopologyNodeInfo }
type ElectReturnInfo ¶
type ElectReturnInfo struct { MasterMiner []mc.TopologyNodeInfo BackUpMiner []mc.TopologyNodeInfo MasterValidator []mc.TopologyNodeInfo BackUpValidator []mc.TopologyNodeInfo }
type ElectValidator ¶
type ElectValidator struct { MasterValidator []mc.TopologyNodeInfo BackUpValidator []mc.TopologyNodeInfo CandidateValidator []mc.TopologyNodeInfo }
type ReElection ¶
type ReElection struct {
// contains filtered or unexported fields
}
func New ¶
func New(bc *core.BlockChain, dbDir string) (*ReElection, error)
func (*ReElection) CalOnline ¶
func (self *ReElection) CalOnline(diff common.NetTopology, top *mc.TopologyGraph) ([]common.Address, []common.Address)
func (*ReElection) CalcbeforeSeedGen ¶
func (self *ReElection) CalcbeforeSeedGen(height uint64) mc.RandomRequest
随机种子生成前的消息准备
func (*ReElection) GetElection ¶
func (self *ReElection) GetElection(height uint64) (*ElectReturnInfo, error)
func (*ReElection) GetHashByNum ¶
func (self *ReElection) GetHashByNum(height uint64) common.Hash
func (*ReElection) GetNativeFromDB ¶
func (self *ReElection) GetNativeFromDB(height uint64) error
func (*ReElection) GetNetTopologyAll ¶
func (self *ReElection) GetNetTopologyAll(height uint64) (*ElectReturnInfo, error)
todo
func (*ReElection) GetSeed ¶
func (self *ReElection) GetSeed(height uint64) (*big.Int, error)
得到随机种子
func (*ReElection) GetTopoChange ¶
func (self *ReElection) GetTopoChange(height uint64, offline []common.Address) ([]mc.Alternative, error)
func (*ReElection) HandleTopGen ¶
func (self *ReElection) HandleTopGen(height uint64) error
func (self *ReElection) HandleNative(height uint64) error { if true == IsinFristPeriod(height) { //第一选举周期不更新 log.INFO(Module, "BlockNum", height, "no need to update native list", "nil") return nil } if true == NeedReadTopoFromDB(height) { //300 600 900 重取缓存 return self.GetNativeFromDB(height) } allNative, err := self.readNativeData(height - 1) // if err != nil { log.Error(Module, "readNativeData failed height", height-1) } log.INFO(Module, "self,allNative", allNative) err = self.UpdateNative(height, allNative) log.INFO(Module,"更新初选列表完毕 错误信息",err) return err }
func (*ReElection) NativeUpdate ¶
func (self *ReElection) NativeUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, online mc.TopologyNodeInfo, flag int) ([]mc.TopologyNodeInfo, []mc.TopologyNodeInfo, []mc.TopologyNodeInfo)
func (*ReElection) ParsePrimaryTopNodeState ¶
func (self *ReElection) ParsePrimaryTopNodeState(topologyChg common.NetTopology) ([]common.Address, []common.Address)
func (*ReElection) ParseTopNodeOffline ¶
func (self *ReElection) ParseTopNodeOffline(topologyChg common.NetTopology, prevTopology *mc.TopologyGraph) []common.Address
func (*ReElection) ToGenMinerTop ¶
func (self *ReElection) ToGenMinerTop(height uint64) error
func (*ReElection) ToGenValidatorTop ¶
func (self *ReElection) ToGenValidatorTop(height uint64) error
func (*ReElection) ToNativeMinerStateUpdate ¶
func (self *ReElection) ToNativeMinerStateUpdate(height uint64, allNative AllNative) (AllNative, error)
func (*ReElection) ToNativeValidatorStateUpdate ¶
func (self *ReElection) ToNativeValidatorStateUpdate(height uint64, allNative AllNative) (AllNative, error)
func (*ReElection) TopoUpdate ¶
func (self *ReElection) TopoUpdate(Q0, Q1, Q2 []mc.TopologyNodeInfo, netTop mc.TopologyGraph, offline []common.Address) []mc.Alternative
func (*ReElection) TransferToElectionStu ¶
func (self *ReElection) TransferToElectionStu(info *ElectReturnInfo) []common.Elect
func (*ReElection) TransferToNetTopologyAllStu ¶
func (self *ReElection) TransferToNetTopologyAllStu(info *ElectReturnInfo) *common.NetTopology
func (*ReElection) TransferToNetTopologyChgStu ¶
func (self *ReElection) TransferToNetTopologyChgStu(alterInfo []mc.Alternative, onlinePrimaryNods []common.Address, offlinePrimaryNodes []common.Address) *common.NetTopology