Documentation ¶
Overview ¶
Copyright (c) 2018-2019 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-2019 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 RegElectPlug(name string, value func() ElectionInterface)
- func RegRandom(name string, fun func(string, RandomChainSupport) (RandomSubService, error))
- func RegVrf(name string, value func() VrfInterface)
- type ChainReader
- type ElectionInterface
- type Random
- type RandomChain
- type RandomChainSupport
- type RandomSubService
- type VrfInterface
Constants ¶
const ( ModuleElection = "选举模块" DefaultElectPlug = "layered" )
const (
ModuleRandom = "随机数接口服务"
)
Variables ¶
var (
DefaultVrfPlug = "withHash"
)
Functions ¶
func RegElectPlug ¶
func RegElectPlug(name string, value func() ElectionInterface)
func RegRandom ¶
func RegRandom(name string, fun func(string, RandomChainSupport) (RandomSubService, error))
func RegVrf ¶
func RegVrf(name string, value func() VrfInterface)
Types ¶
type ChainReader ¶
type ChainReader interface { // Config retrieves the blockchain's chain configuration. Config() *params.ChainConfig // CurrentHeader retrieves the current header from the local chain. CurrentHeader() *types.Header // GetHeader retrieves a block header from the database by hash and number. GetHeader(hash common.Hash, number uint64) *types.Header // GetHeaderByNumber retrieves a block header from the database by number. GetHeaderByNumber(number uint64) *types.Header // GetHeaderByHash retrieves a block header from the database by its hash. GetHeaderByHash(hash common.Hash) *types.Header GetBlockByNumber(number uint64) *types.Block GetAncestorHash(sonHash common.Hash, ancestorNumber uint64) (common.Hash, error) // GetBlock retrieves a block sfrom the database by hash and number. GetBlock(hash common.Hash, number uint64) *types.Block State() (*state.StateDB, error) StateAt(root common.Hash) (*state.StateDB, error) StateAtNumber(number uint64) (*state.StateDB, error) StateAtBlockHash(hash common.Hash) (*state.StateDB, error) GetSuperBlockNum() (uint64, error) GetGraphByState(state matrixstate.StateDB) (*mc.TopologyGraph, *mc.ElectGraph, error) }
type ElectionInterface ¶
type ElectionInterface interface { MinerTopGen(*mc.MasterMinerReElectionReqMsg) *mc.MasterMinerReElectionRsp ValidatorTopGen(*mc.MasterValidatorReElectionReqMsg) *mc.MasterValidatorReElectionRsq ToPoUpdate(support.AllNative, *mc.TopologyGraph) []mc.Alternative }
func NewElect ¶
func NewElect(ElectPlugs string) ElectionInterface
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
func NewRandom ¶
func NewRandom(bc ChainReader) (*Random, error)
type RandomChain ¶
type RandomChain struct {
// contains filtered or unexported fields
}
func (*RandomChain) BlockChain ¶
func (self *RandomChain) BlockChain() ChainReader
type RandomChainSupport ¶
type RandomChainSupport interface {
BlockChain() ChainReader
}
type RandomSubService ¶
type VrfInterface ¶
type VrfInterface interface { ComputeVrf(*ecdsa.PrivateKey, []byte) ([]byte, []byte, error) DecodeVrf(header *types.Header, preHeader *types.Header) (common.Address, error) GetVrfInfoFromHeader([]byte) ([]byte, []byte, []byte) GetHeaderVrf([]byte, []byte, []byte) []byte }
func (self *vrfWithHash)verifyVrf(pk *ecdsa.PublicKey, prevVrf, newVrf, proof []byte) error { func(self *vrfWithHash) computeVrf(sk *ecdsa.PrivateKey,prevVrf []byte) ([]byte, []byte, error) {
func NewVrf ¶
func NewVrf() VrfInterface