ecconnector

package
v0.0.0-...-10c1c44 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GasCeil  = 0x8000000
	GasFloor = 0x8000000
)
View Source
const (
	NewHeadPath        = "/newhead"
	VerifySealPath     = "/verifyseal"
	KeepAlivePath      = "/heartbeat"
	BuildBlkResultPath = "/buildblkresult"
)

Variables

View Source
var Defaults = Config{
	EcUrl:     "https://127.0.0.1:8780",
	SomeParam: "any",
	GasFloor:  8000000,
	GasCeil:   8000000,
}

there are examples, if we need any configuration, we can define it here Defaults contains default settings for ec connector

View Source
var (
	EcGethDummyExtra []byte = []byte("EcGeth Extra")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	BlockChain() *core.BlockChain
	TxPool() *core.TxPool
	BroadcastBlockToAll(block *types.Block)
	SendNewBlock(pidList []string, block *types.Block, td *big.Int)
}

Backend wraps all methods required for mining.

type BlockParam

type BlockParam struct {
	Blockno uint64            `json:"blockno"`
	BHash   string            `json:"bhash"`
	BProof  *ecpon.BlockProof `json:"blockproof"`
}

type BuildBlkRstParam

type BuildBlkRstParam struct {
	PBlockno  uint64 `json:"pblockno"` //parent block no
	NBlockno  uint64 `json:"nblockno"` //new block no
	NBHash    string `json:"nbhash"`   //new block hash
	ErrReason string `json:"errreason"`
}

type Config

type Config struct {
	EcUrl     string //url of rest api of external consensus
	SomeParam string //just example. you can declare anything
	GasFloor  uint64 // Target gas floor for mined blocks.
	GasCeil   uint64 // Target gas ceiling for mined blocks.

}

Config contains configuration options for Ec-geth

type EcBatcher

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

func NewEcBatcher

func NewEcBatcher(eth Backend, config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, mux *event.TypeMux, notifyMinedBlock func(err error, block *types.Block)) *EcBatcher

batcher create a block and seals the block

func (*EcBatcher) SealBlock

func (b *EcBatcher) SealBlock(blk *types.Block, blockProof *ecpon.BlockProof, nextcommittee *ecpon.ConsensusGroup) (*types.Block, error)

func (*EcBatcher) Start

func (b *EcBatcher) Start()

func (*EcBatcher) Stop

func (b *EcBatcher) Stop()

stopping batcher itself

type EcConnector

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

func New

func New(eth Backend, config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, mux *event.TypeMux) *EcConnector

New creates a new External Consensus Connector

func (*EcConnector) BuildBlock

func (ec *EcConnector) BuildBlock(cBlkNo uint64) (string, error)

func (*EcConnector) GetEcRpcHandler

func (ec *EcConnector) GetEcRpcHandler() ecpon.EcRpcCall

func (*EcConnector) GetLastBlockNum

func (ec *EcConnector) GetLastBlockNum() uint64

return last block no

func (*EcConnector) HeartBeat

func (ec *EcConnector) HeartBeat() string

API corressponding rpc are implemented corressponding rpc APIs are implemented in eth/api_ecconnector.go let's implement dummy API

func (*EcConnector) Mining

func (ec *EcConnector) Mining() bool

func (*EcConnector) NotifyMinedBlock

func (ec *EcConnector) NotifyMinedBlock(err error, blk *types.Block)

batcher will call this API if mining block finished

func (*EcConnector) SealBlock

func (ec *EcConnector) SealBlock(blockno uint64, bhash string, proof *ecpon.BlockProof) error

bhash is the block hash of the candidate block, bhash is string form of hash

func (*EcConnector) SetEtherbase

func (ec *EcConnector) SetEtherbase(addr common.Address)

func (*EcConnector) Start

func (ec *EcConnector) Start(coinbase common.Address)

func (*EcConnector) Stop

func (ec *EcConnector) Stop()

type EcError

type EcError struct {
	Code string // error code
	Msg  string // error string
}

defines External Consensus Error

type RpcClient

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

func NewRpcClient

func NewRpcClient(url string) *RpcClient

func (*RpcClient) SendBuildBlkResult

func (r *RpcClient) SendBuildBlkResult(rblkno uint64, blockno uint64, bhash common.Hash, berr error) error

Send result of buildBlock request rblkno: requested blockno which is parent blk, blocno and bhash is for new block

func (*RpcClient) SendKeepAlive

func (r *RpcClient) SendKeepAlive() error

Send KeepAlive, it included cached information

func (*RpcClient) SendNewHead

func (r *RpcClient) SendNewHead(blockno uint64, bhash common.Hash, bproof *ecpon.BlockProof) error

Send NewHeadEv request (a block hash)

func (*RpcClient) SendVerifySeal

func (r *RpcClient) SendVerifySeal(blockno uint64, bhash common.Hash, bproof *ecpon.BlockProof) error

Send VerifySeal request (a block hash)

Jump to

Keyboard shortcuts

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