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
db8170de
Commit
db8170de
authored
Jul 18, 2014
by
Maran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP to expose hashrate to gui
parent
28a146d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
dagger.go
ethchain/dagger.go
+9
-2
miner.go
ethminer/miner.go
+4
-0
No files found.
ethchain/dagger.go
View file @
db8170de
...
@@ -16,10 +16,16 @@ var powlogger = ethlog.NewLogger("POW")
...
@@ -16,10 +16,16 @@ var powlogger = ethlog.NewLogger("POW")
type
PoW
interface
{
type
PoW
interface
{
Search
(
block
*
Block
,
reactChan
chan
ethutil
.
React
)
[]
byte
Search
(
block
*
Block
,
reactChan
chan
ethutil
.
React
)
[]
byte
Verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
Verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
GetHashrate
()
int64
}
}
type
EasyPow
struct
{
type
EasyPow
struct
{
hash
*
big
.
Int
hash
*
big
.
Int
HashRate
int64
}
func
(
pow
*
EasyPow
)
GetHashrate
()
int64
{
return
pow
.
HashRate
}
}
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
reactChan
chan
ethutil
.
React
)
[]
byte
{
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
reactChan
chan
ethutil
.
React
)
[]
byte
{
...
@@ -39,7 +45,8 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
...
@@ -39,7 +45,8 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte {
if
i
%
1234567
==
0
{
if
i
%
1234567
==
0
{
elapsed
:=
time
.
Now
()
.
UnixNano
()
-
start
elapsed
:=
time
.
Now
()
.
UnixNano
()
-
start
hashes
:=
((
float64
(
1e9
)
/
float64
(
elapsed
))
*
float64
(
i
))
/
1000
hashes
:=
((
float64
(
1e9
)
/
float64
(
elapsed
))
*
float64
(
i
))
/
1000
powlogger
.
Infoln
(
"Hashing @"
,
int64
(
hashes
),
"khash"
)
pow
.
HashRate
=
int64
(
hashes
)
powlogger
.
Infoln
(
"Hashing @"
,
int64
(
pow
.
HashRate
),
"khash"
)
}
}
sha
:=
ethcrypto
.
Sha3Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
sha
:=
ethcrypto
.
Sha3Bin
(
big
.
NewInt
(
r
.
Int63
())
.
Bytes
())
...
...
ethminer/miner.go
View file @
db8170de
...
@@ -24,6 +24,10 @@ type Miner struct {
...
@@ -24,6 +24,10 @@ type Miner struct {
quitChan
chan
bool
quitChan
chan
bool
}
}
func
(
self
Miner
)
GetPow
()
*
ethchain
.
PoW
{
return
&
self
.
pow
}
func
NewDefaultMiner
(
coinbase
[]
byte
,
ethereum
ethchain
.
EthManager
)
Miner
{
func
NewDefaultMiner
(
coinbase
[]
byte
,
ethereum
ethchain
.
EthManager
)
Miner
{
reactChan
:=
make
(
chan
ethutil
.
React
,
1
)
// This is the channel that receives 'updates' when ever a new transaction or block comes in
reactChan
:=
make
(
chan
ethutil
.
React
,
1
)
// This is the channel that receives 'updates' when ever a new transaction or block comes in
powChan
:=
make
(
chan
[]
byte
,
1
)
// This is the channel that receives valid sha hases for a given block
powChan
:=
make
(
chan
[]
byte
,
1
)
// This is the channel that receives valid sha hases for a given block
...
...
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