diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-20 03:45:40 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-20 03:45:40 +0800 |
commit | 2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d (patch) | |
tree | fd32a029985128ffa8a0c0581c063d46b94954d2 | |
parent | ed07ffcde5ab661a9fd41045c5ec102e7839001c (diff) | |
download | go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar.gz go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar.bz2 go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar.lz go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar.xz go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.tar.zst go-tangerine-2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d.zip |
miner: removed default timer & update dag when threads > 0
-rw-r--r-- | miner/miner.go | 12 | ||||
-rw-r--r-- | miner/worker.go | 12 |
2 files changed, 8 insertions, 16 deletions
diff --git a/miner/miner.go b/miner/miner.go index a14a195d2..883956370 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -16,9 +16,10 @@ type Miner struct { MinAcceptedGasPrice *big.Int - mining bool - eth core.Backend - pow pow.PoW + threads int + mining bool + eth core.Backend + pow pow.PoW } func New(eth core.Backend, pow pow.PoW, minerThreads int) *Miner { @@ -28,6 +29,7 @@ func New(eth core.Backend, pow pow.PoW, minerThreads int) *Miner { for i := 0; i < minerThreads; i++ { miner.worker.register(NewCpuMiner(i, pow)) } + miner.threads = minerThreads return miner } @@ -40,7 +42,9 @@ func (self *Miner) Start(coinbase common.Address) { self.mining = true self.worker.coinbase = coinbase - self.pow.(*ethash.Ethash).UpdateDAG() + if self.threads > 0 { + self.pow.(*ethash.Ethash).UpdateDAG() + } self.worker.start() diff --git a/miner/worker.go b/miner/worker.go index daabd3db5..63645cd54 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -6,7 +6,6 @@ import ( "sort" "sync" "sync/atomic" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -151,8 +150,6 @@ func (self *worker) register(agent Agent) { func (self *worker) update() { events := self.mux.Subscribe(core.ChainHeadEvent{}, core.ChainSideEvent{}, core.TxPreEvent{}) - timer := time.NewTicker(2 * time.Second) - out: for { select { @@ -171,15 +168,6 @@ out: } case <-self.quit: break out - case <-timer.C: - if glog.V(logger.Detail) && atomic.LoadInt64(&self.mining) == 1 { - glog.Infoln("Hash rate:", self.HashRate(), "Khash") - } - - // XXX In case all mined a possible uncle - if atomic.LoadInt64(&self.atWork) == 0 && atomic.LoadInt64(&self.mining) == 1 { - self.commitNewWork() - } } } |