mc

package
v1.1.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.

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

View Source
const (
	Heartbeat   = "Heartbeat"      // 心跳交易(广播区块Hash对99取余)
	Publickey   = "SeedPublicKey"  // 公钥交易
	Privatekey  = "SeedPrivateKey" // 私钥交易
	CallTheRoll = "CallTheRoll"    //点名交易  (广播节点随机连接1000个点)
)

by hezi //YY 2018-08-18由tx_pool.go转移到此

Variables

View Source
var (
	SubErrorNoThisEvent  = errors.New("SubscribeEvent Failed No This Event")
	PostErrorNoThisEvent = errors.New("PostEvent Failed No This Event")
)

Functions

func PublishEvent

func PublishEvent(aim EventCode, data interface{}) error

func SubscribeEvent

func SubscribeEvent(aim EventCode, ch interface{}) (event.Subscription, error)

Types

type Alternative

type Alternative struct {
	A        common.Address
	B        common.Address
	Position uint16
}

type BlockData

type BlockData struct {
	Header *types.Header
	Txs    types.Transactions
}

type BlockGenor_BroadcastMiningReqMsg

type BlockGenor_BroadcastMiningReqMsg struct {
	BlockMainData *BlockData
}

type BlockLocalVerifyOK

type BlockLocalVerifyOK struct {
	Header    *types.Header // 包含签名列表的header
	BlockHash common.Hash
	Txs       types.Transactions // 交易列表
	Receipts  []*types.Receipt   // 收据
	State     *state.StateDB     // apply state changes here 状态数据库
}

type BlockPOSFinishedNotify

type BlockPOSFinishedNotify struct {
	Number        uint64
	Header        *types.Header // 包含签名列表的header
	ConsensusTurn uint32
	TxsCode       []uint32
}

type BlockToBucket

type BlockToBucket struct {
	Ms     []discover.NodeID
	Height *big.Int
	Role   common.RoleType
}

type BlockToLinker

type BlockToLinker struct {
	Height *big.Int
	Role   common.RoleType
}

type BroadCastEvent

type BroadCastEvent struct {
	Txtyps string
	Height *big.Int
	Data   []byte
}

特殊交易

type Center

type Center struct {
	FeedMap map[EventCode]*event.Feed
}

type DepositDetail

type DepositDetail struct {
	Address    common.Address
	NodeID     discover.NodeID
	Deposit    *big.Int
	WithdrawH  *big.Int
	OnlineTime *big.Int
}

拓扑生成模块

type ElectionEvent

type ElectionEvent struct {
	Seed *big.Int
}

随机数生成响应

type EventCode

type EventCode int
const (
	NewBlockMessage EventCode = iota
	SendBroadCastTx
	HD_MiningReq
	HD_MiningRsp
	HD_BroadcastMiningReq
	HD_BroadcastMiningRsp

	//CA
	CA_RoleUpdated // RoleUpdatedMsg
	CA_ReqCurrentBlock

	//P2P
	P2P_BlkVerifyRequest // BlockVerifyReqMsg

	//Leader service
	Leader_LeaderChangeNotify // LeaderChangeNotify
	Leader_RecoveryState

	//BlockVerify service
	HD_BlkConsensusReq
	HD_BlkConsensusVote
	BlkVerify_VerifyConsensusOK //BlockVerifyConsensusOK
	BlkVerify_POSFinishedNotify //BlockPOSFinishedNotify

	//BlockGenor service
	BlockGenor_HeaderGenerateReq
	HD_NewBlockInsert
	BlockGenor_HeaderVerifyReq
	BlockGenor_NewBlockReady
	HD_FullBlockReq
	HD_FullBlockRsp

	//topnode online
	HD_TopNodeConsensusReq
	HD_TopNodeConsensusVote
	HD_TopNodeConsensusVoteResult

	//leader
	HD_LeaderReelectInquiryReq
	HD_LeaderReelectInquiryRsp
	HD_LeaderReelectReq
	HD_LeaderReelectVote
	HD_LeaderReelectResultBroadcast
	HD_LeaderReelectResultBroadcastRsp

	//Topology
	ReElec_MasterMinerReElectionReq
	ReElec_MasterValidatorElectionReq
	Topo_MasterMinerElectionRsp
	Topo_MasterValidatorElectionRsp

	//random
	ReElec_TopoSeedReq
	Random_TopoSeedRsp

	P2P_HDMSG

	BlockToBuckets
	BlockToLinkers
	SendUdpTx
	LastEventCode
)

type HD_BlkConsensusReqMsg

type HD_BlkConsensusReqMsg struct {
	From          common.Address
	Header        *types.Header
	ConsensusTurn uint32
	TxsCode       []uint32
}

block verify server

type HD_BlockInsertNotify

type HD_BlockInsertNotify struct {
	From   common.Address
	Header *types.Header
}

BolckGenor

type HD_BroadcastMiningRspMsg

type HD_BroadcastMiningRspMsg struct {
	From          common.Address
	BlockMainData *BlockData
}

type HD_ConsensusVote

type HD_ConsensusVote struct {
	SignHash common.Hash
	Round    uint64
	Sign     common.Signature
	From     common.Address
}

共识投票消息

type HD_FullBlockReqMsg

type HD_FullBlockReqMsg struct {
	HeaderHash common.Hash
	Number     uint64
	From       common.Address
}

type HD_FullBlockRspMsg

type HD_FullBlockRspMsg struct {
	Header *types.Header
	Txs    types.Transactions
	From   common.Address
}

type HD_MiningReqMsg

type HD_MiningReqMsg struct {
	From   common.Address
	Header *types.Header
}

Miner Module

type HD_MiningRspMsg

type HD_MiningRspMsg struct {
	From       common.Address
	Number     uint64
	Blockhash  common.Hash
	Difficulty *big.Int
	Nonce      types.BlockNonce
	Coinbase   common.Address
	MixDigest  common.Hash
	Signatures []common.Signature
}

type HD_OnlineConsensusReqs

type HD_OnlineConsensusReqs struct {
	From    common.Address
	ReqList []*OnlineConsensusReq //请求结构
}

在线状态共识请求消息

type HD_OnlineConsensusVoteResultMsg

type HD_OnlineConsensusVoteResultMsg struct {
	Req      *OnlineConsensusReq //请求结构
	SignList []common.Signature  //签名列表
}

共识结果

type HD_OnlineConsensusVotes

type HD_OnlineConsensusVotes struct {
	Votes []HD_ConsensusVote
}

type HD_ReelectInquiryReqMsg

type HD_ReelectInquiryReqMsg struct {
	Number        uint64
	ConsensusTurn uint32
	ReelectTurn   uint32
	TimeStamp     int64 // TODO  考虑作恶,提前时间
	Master        common.Address
	From          common.Address
}

type HD_ReelectInquiryRspMsg

type HD_ReelectInquiryRspMsg struct {
	Number    uint64
	ReqHash   common.Hash
	Type      ReelectRSPType
	AgreeSign common.Signature
	POSResult *HD_BlkConsensusReqMsg
	RLResult  *HD_ReelectLeaderConsensus
	NewBlock  *types.Header
	From      common.Address
}

type HD_ReelectLeaderConsensus

type HD_ReelectLeaderConsensus struct {
	Req       *HD_ReelectLeaderReqMsg
	Votes     []common.Signature
	TimeStamp int64
}

type HD_ReelectLeaderReqMsg

type HD_ReelectLeaderReqMsg struct {
	InquiryReq *HD_ReelectInquiryReqMsg
	AgreeSigns []common.Signature
	TimeStamp  int64
}

type HD_ReelectLeaderVoteMsg

type HD_ReelectLeaderVoteMsg struct {
	Vote   HD_ConsensusVote
	Number uint64
}

type HD_ReelectResultBroadcastMsg

type HD_ReelectResultBroadcastMsg struct {
	Number    uint64
	Type      ReelectRSPType
	POSResult *HD_BlkConsensusReqMsg
	RLResult  *HD_ReelectLeaderConsensus
	TimeStamp int64
	From      common.Address
}

type HD_ReelectResultRspMsg

type HD_ReelectResultRspMsg struct {
	Number     uint64
	ResultHash common.Hash
	Sign       common.Signature
	From       common.Address
}

type HdRev

type HdRev struct {
	FromNodeId string
	Input      interface{}
}

type LeaderChangeNotify

type LeaderChangeNotify struct {
	ConsensusState bool //共识结果
	Leader         common.Address
	NextLeader     common.Address
	Number         uint64
	ConsensusTurn  uint32
	ReelectTurn    uint32
	TurnBeginTime  int64
	TurnEndTime    int64
}

type LeaderStateMsg

type LeaderStateMsg struct {
	Leader      common.Address
	Number      big.Int
	ReelectTurn uint8
}

type LocalBlockVerifyConsensusReq

type LocalBlockVerifyConsensusReq struct {
	BlkVerifyConsensusReq *HD_BlkConsensusReqMsg
	Txs                   types.Transactions // 交易列表
	Receipts              []*types.Receipt   // 收据
	State                 *state.StateDB     // apply state changes here 状态数据库
}

type MasterMinerReElectionReqMsg

type MasterMinerReElectionReqMsg struct {
	SeqNum    uint64
	RandSeed  *big.Int
	MinerList []vm.DepositDetail
}

矿工主节点生成请求

type MasterMinerReElectionRsp

type MasterMinerReElectionRsp struct {
	SeqNum      uint64
	MasterMiner []TopologyNodeInfo
	BackUpMiner []TopologyNodeInfo
}

矿工主节点生成响应

type MasterMinerReElectionRspMsg

type MasterMinerReElectionRspMsg struct {
	SeqNum uint64
}

Election Module

type MasterValidatorReElectionReqMsg

type MasterValidatorReElectionReqMsg struct {
	SeqNum                  uint64
	RandSeed                *big.Int
	ValidatorList           []vm.DepositDetail
	FoundationValidatoeList []vm.DepositDetail
}

验证者主节点生成请求

type MasterValidatorReElectionRspMsg

type MasterValidatorReElectionRspMsg struct {
	SeqNum uint64
}

type MasterValidatorReElectionRsq

type MasterValidatorReElectionRsq struct {
	SeqNum             uint64
	MasterValidator    []TopologyNodeInfo
	BackUpValidator    []TopologyNodeInfo
	CandidateValidator []TopologyNodeInfo
}

验证者主节点生成响应

type NewBlockReadyMsg

type NewBlockReadyMsg struct {
	Header *types.Header
}

type OnlineConsensusReq

type OnlineConsensusReq struct {
	Leader      common.Address //leader地址
	Seq         uint64         //共识轮次
	Node        common.Address // node 地址
	OnlineState int            //在线状态
}

在线状态共识请求

type RandomRequest

type RandomRequest struct {
	MinHash    common.Hash
	PrivateMap map[common.Address][]byte
	PublicMap  map[common.Address][]byte
}

随机数生成请求

type RecoveryStateMsg

type RecoveryStateMsg struct {
	Type   RecoveryType
	Header *types.Header
	From   common.Address
}

type RecoveryType

type RecoveryType uint8
const (
	RecoveryTypePOS RecoveryType = iota
	RecoveryTypeFullHeader
)

type ReelectRSPType

type ReelectRSPType uint8
const (
	ReelectRSPTypeNone ReelectRSPType = iota
	ReelectRSPTypePOS
	ReelectRSPTypeAlreadyRL
	ReelectRSPTypeAgree
	ReelectRSPTypeNewBlockReady
)

type RoleUpdatedMsg

type RoleUpdatedMsg struct {
	Role      common.RoleType
	BlockNum  uint64
	BlockHash common.Hash
	Leader    common.Address
}

type TopologyGraph

type TopologyGraph struct {
	Number        uint64
	NodeList      []TopologyNodeInfo
	CurNodeNumber uint8
}

func NewGenesisTopologyGraph

func NewGenesisTopologyGraph(genesisHeader *types.Header) (*TopologyGraph, error)

func (*TopologyGraph) Transfer2NextGraph

func (self *TopologyGraph) Transfer2NextGraph(number uint64, blockTopology *common.NetTopology, electList []common.Elect) (*TopologyGraph, error)

type TopologyNodeInfo

type TopologyNodeInfo struct {
	Account    common.Address
	Position   uint16
	Type       common.RoleType
	Stock      uint16
	NodeNumber uint8 //0-99

}

Jump to

Keyboard shortcuts

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