Documentation
¶
Index ¶
- Constants
- Variables
- type Backend
- type BlockParam
- type BuildBlkRstParam
- type Config
- type EcBatcher
- type EcConnector
- func (ec *EcConnector) BuildBlock(cBlkNo uint64) (string, error)
- func (ec *EcConnector) GetEcRpcHandler() ecpon.EcRpcCall
- func (ec *EcConnector) GetLastBlockNum() uint64
- func (ec *EcConnector) HeartBeat() string
- func (ec *EcConnector) Mining() bool
- func (ec *EcConnector) NotifyMinedBlock(err error, blk *types.Block)
- func (ec *EcConnector) SealBlock(blockno uint64, bhash string, proof *ecpon.BlockProof) error
- func (ec *EcConnector) SetEtherbase(addr common.Address)
- func (ec *EcConnector) Start(coinbase common.Address)
- func (ec *EcConnector) Stop()
- type EcError
- type RpcClient
- func (r *RpcClient) SendBuildBlkResult(rblkno uint64, blockno uint64, bhash common.Hash, berr error) error
- func (r *RpcClient) SendKeepAlive() error
- func (r *RpcClient) SendNewHead(blockno uint64, bhash common.Hash, bproof *ecpon.BlockProof) error
- func (r *RpcClient) SendVerifySeal(blockno uint64, bhash common.Hash, bproof *ecpon.BlockProof) error
Constants ¶
const ( GasCeil = 0x8000000 GasFloor = 0x8000000 )
const ( NewHeadPath = "/newhead" VerifySealPath = "/verifyseal" KeepAlivePath = "/heartbeat" BuildBlkResultPath = "/buildblkresult" )
Variables ¶
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
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 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
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 RpcClient ¶
type RpcClient struct {
// contains filtered or unexported fields
}
func NewRpcClient ¶
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 ¶
Send KeepAlive, it included cached information
func (*RpcClient) SendNewHead ¶
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)