aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-12 06:35:34 +0800
committerFelix Lange <fjl@twurst.com>2015-03-12 06:43:27 +0800
commitd7b5a87b3bc4a19677877d3a8c8c925211eb25f1 (patch)
treef43c6b29c27dd29cc366788353650faa1d45e7bb /xeth
parent5a9f712144058c576d14b0d27ff2d2d270cd6d27 (diff)
downloadgo-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar.gz
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar.bz2
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar.lz
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar.xz
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.tar.zst
go-tangerine-d7b5a87b3bc4a19677877d3a8c8c925211eb25f1.zip
miner: provide coinbase when starting the miner
This avoids having to query the coinbase when creating the miner, which in turn eliminates the dreaded startup error when no accounts are set up. Later, this will also allow us to simply restart the miner when the user picks a different coinbase. This causes a lot of changes in other packages. These are included in this commit because they're impossible to separate.
Diffstat (limited to 'xeth')
-rw-r--r--xeth/xeth.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index d8dd66aec..70172a1c8 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -14,7 +14,6 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/whisper"
@@ -35,7 +34,10 @@ type Backend interface {
StateDb() ethutil.Database
EventMux() *event.TypeMux
Whisper() *whisper.Whisper
- Miner() *miner.Miner
+
+ IsMining() bool
+ StartMining() error
+ StopMining()
}
// Frontend should be implemented by users of XEth. Its methods are
@@ -65,7 +67,6 @@ type XEth struct {
accountManager *accounts.Manager
state *State
whisper *Whisper
- miner *miner.Miner
frontend Frontend
}
@@ -87,7 +88,6 @@ func New(eth Backend, frontend Frontend) *XEth {
chainManager: eth.ChainManager(),
accountManager: eth.AccountManager(),
whisper: NewWhisper(eth.Whisper()),
- miner: eth.Miner(),
frontend: frontend,
}
if frontend == nil {
@@ -104,7 +104,6 @@ func (self *XEth) WithState(statedb *state.StateDB) *XEth {
blockProcessor: self.blockProcessor,
chainManager: self.chainManager,
whisper: self.whisper,
- miner: self.miner,
}
xeth.state = NewState(xeth, statedb)
@@ -112,8 +111,7 @@ func (self *XEth) WithState(statedb *state.StateDB) *XEth {
}
func (self *XEth) State() *State { return self.state }
-func (self *XEth) Whisper() *Whisper { return self.whisper }
-func (self *XEth) Miner() *miner.Miner { return self.miner }
+func (self *XEth) Whisper() *Whisper { return self.whisper }
func (self *XEth) BlockByHash(strHash string) *Block {
hash := fromHex(strHash)
@@ -172,18 +170,19 @@ func (self *XEth) PeerCount() int {
}
func (self *XEth) IsMining() bool {
- return self.miner.Mining()
+ return self.eth.IsMining()
}
func (self *XEth) SetMining(shouldmine bool) bool {
- ismining := self.miner.Mining()
+ ismining := self.eth.IsMining()
if shouldmine && !ismining {
- self.miner.Start()
+ err := self.eth.StartMining()
+ return err == nil
}
if ismining && !shouldmine {
- self.miner.Stop()
+ self.eth.StopMining()
}
- return self.miner.Mining()
+ return self.eth.IsMining()
}
func (self *XEth) IsListening() bool {