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
0eb08693
Commit
0eb08693
authored
Aug 21, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbo mode
parent
cc6ad034
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
dagger.go
ethchain/dagger.go
+15
-4
No files found.
ethchain/dagger.go
View file @
0eb08693
package
ethchain
package
ethchain
import
(
import
(
"hash"
"math/big"
"math/rand"
"time"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/sha3"
"github.com/obscuren/sha3"
"hash"
"math/big"
"math/rand"
"time"
)
)
var
powlogger
=
ethlog
.
NewLogger
(
"POW"
)
var
powlogger
=
ethlog
.
NewLogger
(
"POW"
)
...
@@ -18,17 +19,23 @@ type PoW interface {
...
@@ -18,17 +19,23 @@ type PoW interface {
Search
(
block
*
Block
,
reactChan
chan
ethreact
.
Event
)
[]
byte
Search
(
block
*
Block
,
reactChan
chan
ethreact
.
Event
)
[]
byte
Verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
Verify
(
hash
[]
byte
,
diff
*
big
.
Int
,
nonce
[]
byte
)
bool
GetHashrate
()
int64
GetHashrate
()
int64
Turbo
(
bool
)
}
}
type
EasyPow
struct
{
type
EasyPow
struct
{
hash
*
big
.
Int
hash
*
big
.
Int
HashRate
int64
HashRate
int64
turbo
bool
}
}
func
(
pow
*
EasyPow
)
GetHashrate
()
int64
{
func
(
pow
*
EasyPow
)
GetHashrate
()
int64
{
return
pow
.
HashRate
return
pow
.
HashRate
}
}
func
(
pow
*
EasyPow
)
Turbo
(
on
bool
)
{
pow
.
turbo
=
on
}
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
reactChan
chan
ethreact
.
Event
)
[]
byte
{
func
(
pow
*
EasyPow
)
Search
(
block
*
Block
,
reactChan
chan
ethreact
.
Event
)
[]
byte
{
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
hash
:=
block
.
HashNoNonce
()
hash
:=
block
.
HashNoNonce
()
...
@@ -55,6 +62,10 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
...
@@ -55,6 +62,10 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethreact.Event) []byte {
return
sha
return
sha
}
}
}
}
if
!
pow
.
turbo
{
time
.
Sleep
(
500
*
time
.
Millisecond
)
}
}
}
return
nil
return
nil
...
...
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