From 8135752a32837748e6d4a986912131736b1a0aa0 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 17 Feb 2015 12:24:51 +0100
Subject: "centralised" mining to backend. Closes #323

---
 xeth/xeth.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

(limited to 'xeth/xeth.go')

diff --git a/xeth/xeth.go b/xeth/xeth.go
index 75d83f80b..27435b956 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -14,6 +14,7 @@ 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"
@@ -27,13 +28,13 @@ type Backend interface {
 	ChainManager() *core.ChainManager
 	TxPool() *core.TxPool
 	PeerCount() int
-	IsMining() bool
 	IsListening() bool
 	Peers() []*p2p.Peer
 	KeyManager() *crypto.KeyManager
 	Db() ethutil.Database
 	EventMux() *event.TypeMux
 	Whisper() *whisper.Whisper
+	Miner() *miner.Miner
 }
 
 type XEth struct {
@@ -42,6 +43,7 @@ type XEth struct {
 	chainManager   *core.ChainManager
 	state          *State
 	whisper        *Whisper
+	miner          *miner.Miner
 }
 
 func New(eth Backend) *XEth {
@@ -50,15 +52,17 @@ func New(eth Backend) *XEth {
 		blockProcessor: eth.BlockProcessor(),
 		chainManager:   eth.ChainManager(),
 		whisper:        NewWhisper(eth.Whisper()),
+		miner:          eth.Miner(),
 	}
 	xeth.state = NewState(xeth)
 
 	return xeth
 }
 
-func (self *XEth) Backend() Backend  { return self.eth }
-func (self *XEth) State() *State     { return self.state }
-func (self *XEth) Whisper() *Whisper { return self.whisper }
+func (self *XEth) Backend() Backend    { return self.eth }
+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) BlockByHash(strHash string) *Block {
 	hash := fromHex(strHash)
@@ -96,7 +100,7 @@ func (self *XEth) PeerCount() int {
 }
 
 func (self *XEth) IsMining() bool {
-	return self.eth.IsMining()
+	return self.miner.Mining()
 }
 
 func (self *XEth) IsListening() bool {
-- 
cgit v1.2.3