From 068cb794976da713fb4671e1bb4e4657d3dcc2b3 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 12 Aug 2019 00:00:20 -0400 Subject: ... --- coreth.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'coreth.go') diff --git a/coreth.go b/coreth.go index c7b5e42..e43ce3e 100644 --- a/coreth.go +++ b/coreth.go @@ -27,8 +27,8 @@ type Hash = common.Hash type ETHChain struct { mux *event.TypeMux - worker *miner.Worker backend *eth.Ethereum + worker *miner.Worker } type DummyEngine struct { @@ -248,7 +248,7 @@ func isLocalBlock(block *types.Block) bool { return false } -func NewETHChain(config *miner.Config, chainConfig *params.ChainConfig) *ETHChain { +func NewETHChain(config *miner.Config, chainConfig *params.ChainConfig, etherBase *common.Address) *ETHChain { if config == nil { config = ð.DefaultConfig.Miner } @@ -260,11 +260,31 @@ func NewETHChain(config *miner.Config, chainConfig *params.ChainConfig) *ETHChai backend, _ := eth.New(&ctx, ð.DefaultConfig) chain := ÐChain { mux: mux, + backend: backend, worker: miner.NewWorker(config, chainConfig, &DummyEngine{}, backend, mux, isLocalBlock), } + if etherBase == nil { + etherBase = &common.Address{ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } + } + chain.worker.SetEtherbase(*etherBase) return chain } func (self *ETHChain) Start() { self.worker.Start() } + +func (self *ETHChain) Stop() { + self.worker.Stop() +} + +func (self *ETHChain) AddRemoteTxs(txs []*types.Transaction) []error { + return self.backend.TxPool().AddRemotes(txs) +} + +func (self *ETHChain) AddLocalTxs(txs []*types.Transaction) []error { + return self.backend.TxPool().AddLocals(txs) +} -- cgit v1.2.3-70-g09d2