From 0424afc658dae706b017aeb3d6208026c1f6f547 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 30 Aug 2019 09:00:43 -0400 Subject: add callbacks for the miner --- coreth.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'coreth.go') diff --git a/coreth.go b/coreth.go index 03f9adf..f7c54d6 100644 --- a/coreth.go +++ b/coreth.go @@ -7,6 +7,7 @@ import ( "github.com/ava-labs/coreth/consensus/dummy" "github.com/ava-labs/coreth/eth" + "github.com/ava-labs/coreth/miner" "github.com/ava-labs/coreth/node" "github.com/ava-labs/go-ethereum/common" "github.com/ava-labs/go-ethereum/core/state" @@ -24,6 +25,7 @@ type Hash = common.Hash type ETHChain struct { backend *eth.Ethereum cb *dummy.ConsensusCallbacks + mcb *miner.MinerCallbacks } func isLocalBlock(block *types.Block) bool { @@ -37,8 +39,9 @@ func NewETHChain(config *eth.Config, etherBase *common.Address) *ETHChain { mux := new(event.TypeMux) ctx := node.NewServiceContext(mux) cb := new(dummy.ConsensusCallbacks) - backend, _ := eth.New(&ctx, config, cb) - chain := ÐChain{backend: backend, cb: cb} + mcb := new(miner.MinerCallbacks) + backend, _ := eth.New(&ctx, config, cb, mcb) + chain := ÐChain{backend: backend, cb: cb, mcb: mcb} if etherBase == nil { etherBase = &common.Address{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -73,6 +76,10 @@ func (self *ETHChain) SetOnSeal(cb func(*types.Block) error) { self.cb.OnSeal = cb } +func (self *ETHChain) SetOnSealMiner(cb func(*types.Block) error) { + self.mcb.OnSeal = cb +} + func (self *ETHChain) SetOnAPIs(cb dummy.OnAPIsCallbackType) { self.cb.OnAPIs = cb } -- cgit v1.2.3