Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
2c1a6a34
Commit
2c1a6a34
authored
Apr 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
miner: removed default timer & update dag when threads > 0
parent
ed07ffcd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
16 deletions
+8
-16
miner.go
miner/miner.go
+8
-4
worker.go
miner/worker.go
+0
-12
No files found.
miner/miner.go
View file @
2c1a6a34
...
...
@@ -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
()
...
...
miner/worker.go
View file @
2c1a6a34
...
...
@@ -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
()
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment