aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-18 18:21:11 +0800
committerobscuren <geffobscura@gmail.com>2014-07-18 18:21:11 +0800
commitdad29bcaa12d7b170d81a9f5a44a5faa119bd210 (patch)
treed73b7d80f46e6f4fb71cb85c73969b2b91e0fd14
parent65650a5c66d03b64c24ec3247ac1c7cdac25b74a (diff)
downloaddexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar.gz
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar.bz2
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar.lz
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar.xz
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.tar.zst
dexon-dad29bcaa12d7b170d81a9f5a44a5faa119bd210.zip
Added channel for starting/stopping miner
-rw-r--r--ethminer/miner.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/ethminer/miner.go b/ethminer/miner.go
index f45615b62..fd14571cd 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -24,11 +24,11 @@ type Miner struct {
quitChan chan bool
}
-func (self Miner) GetPow() *ethchain.PoW {
- return &self.pow
+func (self *Miner) GetPow() ethchain.PoW {
+ return self.pow
}
-func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
+func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) *Miner {
reactChan := make(chan ethutil.React, 1) // This is the channel that receives 'updates' when ever a new transaction or block comes in
powChan := make(chan []byte, 1) // This is the channel that receives valid sha hases for a given block
powQuitChan := make(chan ethutil.React, 1) // This is the channel that can exit the miner thread
@@ -59,7 +59,7 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner {
miner.txs = ethereum.TxPool().Flush()
miner.block = ethereum.BlockChain().NewBlock(miner.coinbase)
- return miner
+ return &miner
}
func (miner *Miner) Start() {
@@ -67,6 +67,8 @@ func (miner *Miner) Start() {
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
go miner.listener()
logger.Infoln("Started")
+
+ miner.ethereum.Reactor().Post("miner:start", miner)
}
func (miner *Miner) listener() {
@@ -137,6 +139,8 @@ func (self *Miner) Stop() {
close(self.powQuitChan)
close(self.quitChan)
+
+ self.ethereum.Reactor().Post("miner:stop", self)
}
func (self *Miner) mineNewBlock() {