Skip to content

Commit 2c1a6a3

Browse files
committed
miner: removed default timer & update dag when threads > 0
1 parent ed07ffc commit 2c1a6a3

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

‎miner/miner.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ type Miner struct {
1616

1717
MinAcceptedGasPrice *big.Int
1818

19-
mining bool
20-
eth core.Backend
21-
pow pow.PoW
19+
threads int
20+
mining bool
21+
eth core.Backend
22+
pow pow.PoW
2223
}
2324

2425
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 {
2829
for i := 0; i < minerThreads; i++ {
2930
miner.worker.register(NewCpuMiner(i, pow))
3031
}
32+
miner.threads = minerThreads
3133

3234
return miner
3335
}
@@ -40,7 +42,9 @@ func (self *Miner) Start(coinbase common.Address) {
4042
self.mining = true
4143
self.worker.coinbase = coinbase
4244

43-
self.pow.(*ethash.Ethash).UpdateDAG()
45+
if self.threads > 0 {
46+
self.pow.(*ethash.Ethash).UpdateDAG()
47+
}
4448

4549
self.worker.start()
4650

‎miner/worker.go‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sort"
77
"sync"
88
"sync/atomic"
9-
"time"
109

1110
"github.com/ethereum/go-ethereum/common"
1211
"github.com/ethereum/go-ethereum/core"
@@ -151,8 +150,6 @@ func (self *worker) register(agent Agent) {
151150
func (self *worker) update() {
152151
events := self.mux.Subscribe(core.ChainHeadEvent{}, core.ChainSideEvent{}, core.TxPreEvent{})
153152

154-
timer := time.NewTicker(2 * time.Second)
155-
156153
out:
157154
for {
158155
select {
@@ -171,15 +168,6 @@ out:
171168
}
172169
case <-self.quit:
173170
break out
174-
case <-timer.C:
175-
if glog.V(logger.Detail) && atomic.LoadInt64(&self.mining) == 1 {
176-
glog.Infoln("Hash rate:", self.HashRate(), "Khash")
177-
}
178-
179-
// XXX In case all mined a possible uncle
180-
if atomic.LoadInt64(&self.atWork) == 0 && atomic.LoadInt64(&self.mining) == 1 {
181-
self.commitNewWork()
182-
}
183171
}
184172
}
185173

0 commit comments

Comments
 (0)