diff options
author | zelig <viktor.tron@gmail.com> | 2014-06-27 01:45:57 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-06-27 01:45:57 +0800 |
commit | 853053a3b204ddf4ae935e70e0aa5b5d8994493e (patch) | |
tree | 8e86c3aa0f913288f2a789c3517444e6fe0583b9 /ethminer/miner.go | |
parent | da38faa8f7c0f2a6620b54e46fc38a201845e104 (diff) | |
download | dexon-853053a3b204ddf4ae935e70e0aa5b5d8994493e.tar.gz dexon-853053a3b204ddf4ae935e70e0aa5b5d8994493e.tar.zst dexon-853053a3b204ddf4ae935e70e0aa5b5d8994493e.zip |
go fmt
Diffstat (limited to 'ethminer/miner.go')
-rw-r--r-- | ethminer/miner.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ethminer/miner.go b/ethminer/miner.go index 2c1645672..66388723e 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -3,9 +3,9 @@ package ethminer import ( "bytes" "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" - "github.com/ethereum/eth-go/ethlog" "sort" ) @@ -57,18 +57,23 @@ func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) Miner { return miner } + func (miner *Miner) Start() { // Prepare inital block //miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) go miner.listener() + logger.Infoln("Started") } + func (miner *Miner) listener() { out: for { select { case <-miner.quitChan: + logger.Infoln("Stopped") break out case chanMessage := <-miner.reactChan: + if block, ok := chanMessage.Resource.(*ethchain.Block); ok { //logger.Infoln("Got new block via Reactor") if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 { @@ -123,8 +128,9 @@ out: } func (self *Miner) Stop() { - self.powQuitChan <- ethutil.React{} + logger.Infoln("Stopping...") self.quitChan <- true + self.powQuitChan <- ethutil.React{} } func (self *Miner) mineNewBlock() { |