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
65cad14f
Commit
65cad14f
authored
Feb 28, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report debug hash rate
parent
fdf939a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
miner.go
miner/miner.go
+1
-6
worker.go
miner/worker.go
+14
-0
No files found.
miner/miner.go
View file @
65cad14f
...
@@ -52,10 +52,5 @@ func (self *Miner) Stop() {
...
@@ -52,10 +52,5 @@ func (self *Miner) Stop() {
}
}
func
(
self
*
Miner
)
HashRate
()
int64
{
func
(
self
*
Miner
)
HashRate
()
int64
{
var
tot
int64
return
self
.
worker
.
HashRate
()
for
_
,
agent
:=
range
self
.
worker
.
agents
{
tot
+=
agent
.
Pow
()
.
GetHashrate
()
}
return
tot
}
}
miner/worker.go
View file @
65cad14f
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"math/big"
"math/big"
"sort"
"sort"
"sync"
"sync"
"time"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
...
@@ -111,6 +112,8 @@ func (self *worker) register(agent Agent) {
...
@@ -111,6 +112,8 @@ func (self *worker) register(agent Agent) {
func
(
self
*
worker
)
update
()
{
func
(
self
*
worker
)
update
()
{
events
:=
self
.
mux
.
Subscribe
(
core
.
ChainEvent
{},
core
.
NewMinedBlockEvent
{})
events
:=
self
.
mux
.
Subscribe
(
core
.
ChainEvent
{},
core
.
NewMinedBlockEvent
{})
timer
:=
time
.
NewTicker
(
2
*
time
.
Second
)
out
:
out
:
for
{
for
{
select
{
select
{
...
@@ -129,6 +132,8 @@ out:
...
@@ -129,6 +132,8 @@ out:
agent
.
Stop
()
agent
.
Stop
()
}
}
break
out
break
out
case
<-
timer
.
C
:
minerlogger
.
Debugln
(
"Hash rate:"
,
self
.
HashRate
(),
"Khash"
)
}
}
}
}
...
@@ -244,3 +249,12 @@ func (self *worker) commitTransaction(tx *types.Transaction) error {
...
@@ -244,3 +249,12 @@ func (self *worker) commitTransaction(tx *types.Transaction) error {
return
nil
return
nil
}
}
func
(
self
*
worker
)
HashRate
()
int64
{
var
tot
int64
for
_
,
agent
:=
range
self
.
agents
{
tot
+=
agent
.
Pow
()
.
GetHashrate
()
}
return
tot
}
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