baseinterface

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: 13 Imported by: 0

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

Index

Constants

View Source
const (
	ModuleElection   = "选举模块"
	DefaultElectPlug = "layered"
)
View Source
const (
	ModuleRandom = "随机数接口服务"
)

Variables

View Source
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
	StateAt(root []common.CoinRoot) (*state.StateDBManage, error)
	State() (*state.StateDBManage, error)
	StateAtNumber(number uint64) (*state.StateDBManage, error)
	StateAtBlockHash(hash common.Hash) (*state.StateDBManage, error)
	GetSuperBlockNum() (uint64, error)
	GetGraphByState(state matrixstate.StateDB) (*mc.TopologyGraph, *mc.ElectGraph, error)
}

type Random

type Random struct {
	// contains filtered or unexported fields
}

func NewRandom

func NewRandom(bc ChainReader) (*Random, error)

func (*Random) GetRandom

func (self *Random) GetRandom(hash common.Hash, Type string) (*big.Int, error)

func (*Random) Stop

func (self *Random) Stop()

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 RandomSubService interface {
	Prepare(uint64, common.Hash) error
	CalcData(data common.Hash) (*big.Int, error)
}

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

Jump to

Keyboard shortcuts

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