diff options
author | Ted Yin <[email protected]> | 2020-09-18 13:14:29 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-18 13:14:29 -0400 |
commit | d048937c48753d9eaef771bf71820cf95d79df26 (patch) | |
tree | 1a7f65fcd72e77092525ab01625b8b9d365e3e40 /coreth.go | |
parent | 7d1388c743b4ec8f4a86bea95bfada785dee83f7 (diff) | |
parent | 7d8c85cf8895b0f998d8eafb02f99d5b689fcd59 (diff) |
Merge pull request #34 from ava-labs/devv0.3.0-rc.5
Dev
Diffstat (limited to 'coreth.go')
-rw-r--r-- | coreth.go | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -2,7 +2,7 @@ package coreth import ( "crypto/ecdsa" - "fmt" + //"fmt" "io" "os" @@ -14,11 +14,13 @@ import ( "github.com/ava-labs/coreth/miner" "github.com/ava-labs/coreth/node" "github.com/ava-labs/coreth/rpc" - "github.com/ava-labs/go-ethereum/common" - "github.com/ava-labs/go-ethereum/crypto" - "github.com/ava-labs/go-ethereum/ethdb" - "github.com/ava-labs/go-ethereum/event" - "github.com/ava-labs/go-ethereum/log" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/trie" + //"github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" "github.com/mattn/go-isatty" ) @@ -52,18 +54,18 @@ func NewETHChain(config *eth.Config, nodecfg *node.Config, etherBase *common.Add if nodecfg == nil { nodecfg = &node.Config{} } - mux := new(event.TypeMux) - ctx, ep, err := node.NewServiceContext(nodecfg, mux) + //mux := new(event.TypeMux) + node, err := node.New(nodecfg) if err != nil { panic(err) } - if ep != "" { - log.Info(fmt.Sprintf("temporary keystore = %s", ep)) - } + //if ep != "" { + // log.Info(fmt.Sprintf("temporary keystore = %s", ep)) + //} cb := new(dummy.ConsensusCallbacks) mcb := new(miner.MinerCallbacks) bcb := new(eth.BackendCallbacks) - backend, _ := eth.New(&ctx, config, cb, mcb, bcb, chainDB) + backend, _ := eth.New(node, config, cb, mcb, bcb, chainDB) chain := ÐChain{backend: backend, cb: cb, mcb: mcb, bcb: bcb} if etherBase == nil { etherBase = &BlackholeAddr @@ -84,8 +86,12 @@ func (self *ETHChain) GenBlock() { self.backend.Miner().GenBlock() } +func (self *ETHChain) SubscribeNewMinedBlockEvent() *event.TypeMuxSubscription { + return self.backend.Miner().GetWorkerMux().Subscribe(core.NewMinedBlockEvent{}) +} + func (self *ETHChain) VerifyBlock(block *types.Block) bool { - txnHash := types.DeriveSha(block.Transactions()) + txnHash := types.DeriveSha(block.Transactions(), new(trie.Trie)) uncleHash := types.CalcUncleHash(block.Uncles()) ethHeader := block.Header() if txnHash != ethHeader.TxHash || uncleHash != ethHeader.UncleHash { |