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
c5df37c1
Commit
c5df37c1
authored
Jan 12, 2017
by
Felix Lange
Committed by
GitHub
Jan 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: accept leading zeros for nonce parameter of submitWork (#3558)
parent
e0ceeab0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
6 deletions
+8
-6
block.go
core/types/block.go
+2
-2
api.go
eth/api.go
+2
-2
agent.go
miner/agent.go
+2
-1
remote_agent.go
miner/remote_agent.go
+2
-1
No files found.
core/types/block.go
View file @
c5df37c1
...
@@ -423,9 +423,9 @@ func CalcUncleHash(uncles []*Header) common.Hash {
...
@@ -423,9 +423,9 @@ func CalcUncleHash(uncles []*Header) common.Hash {
// WithMiningResult returns a new block with the data from b
// WithMiningResult returns a new block with the data from b
// where nonce and mix digest are set to the provided values.
// where nonce and mix digest are set to the provided values.
func
(
b
*
Block
)
WithMiningResult
(
nonce
uint64
,
mixDigest
common
.
Hash
)
*
Block
{
func
(
b
*
Block
)
WithMiningResult
(
nonce
BlockNonce
,
mixDigest
common
.
Hash
)
*
Block
{
cpy
:=
*
b
.
header
cpy
:=
*
b
.
header
binary
.
BigEndian
.
PutUint64
(
cpy
.
Nonce
[
:
],
nonce
)
cpy
.
Nonce
=
nonce
cpy
.
MixDigest
=
mixDigest
cpy
.
MixDigest
=
mixDigest
return
&
Block
{
return
&
Block
{
header
:
&
cpy
,
header
:
&
cpy
,
...
...
eth/api.go
View file @
c5df37c1
...
@@ -96,8 +96,8 @@ func (s *PublicMinerAPI) Mining() bool {
...
@@ -96,8 +96,8 @@ func (s *PublicMinerAPI) Mining() bool {
// SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was
// SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was
// accepted. Note, this is not an indication if the provided work was valid!
// accepted. Note, this is not an indication if the provided work was valid!
func
(
s
*
PublicMinerAPI
)
SubmitWork
(
nonce
hexutil
.
Uint64
,
solution
,
digest
common
.
Hash
)
bool
{
func
(
s
*
PublicMinerAPI
)
SubmitWork
(
nonce
types
.
BlockNonce
,
solution
,
digest
common
.
Hash
)
bool
{
return
s
.
agent
.
SubmitWork
(
uint64
(
nonce
)
,
digest
,
solution
)
return
s
.
agent
.
SubmitWork
(
nonce
,
digest
,
solution
)
}
}
// GetWork returns a work package for external miner. The work package consists of 3 strings
// GetWork returns a work package for external miner. The work package consists of 3 strings
...
...
miner/agent.go
View file @
c5df37c1
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"sync/atomic"
"sync/atomic"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
...
@@ -112,7 +113,7 @@ func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
...
@@ -112,7 +113,7 @@ func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
// Mine
// Mine
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
work
.
Block
,
stop
,
self
.
index
)
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
work
.
Block
,
stop
,
self
.
index
)
if
nonce
!=
0
{
if
nonce
!=
0
{
block
:=
work
.
Block
.
WithMiningResult
(
nonce
,
common
.
BytesToHash
(
mixDigest
))
block
:=
work
.
Block
.
WithMiningResult
(
types
.
EncodeNonce
(
nonce
)
,
common
.
BytesToHash
(
mixDigest
))
self
.
returnCh
<-
&
Result
{
work
,
block
}
self
.
returnCh
<-
&
Result
{
work
,
block
}
}
else
{
}
else
{
self
.
returnCh
<-
nil
self
.
returnCh
<-
nil
...
...
miner/remote_agent.go
View file @
c5df37c1
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
...
@@ -132,7 +133,7 @@ func (a *RemoteAgent) GetWork() ([3]string, error) {
...
@@ -132,7 +133,7 @@ func (a *RemoteAgent) GetWork() ([3]string, error) {
// SubmitWork tries to inject a PoW solution tinto the remote agent, returning
// SubmitWork tries to inject a PoW solution tinto the remote agent, returning
// whether the solution was acceted or not (not can be both a bad PoW as well as
// whether the solution was acceted or not (not can be both a bad PoW as well as
// any other error, like no work pending).
// any other error, like no work pending).
func
(
a
*
RemoteAgent
)
SubmitWork
(
nonce
uint64
,
mixDigest
,
hash
common
.
Hash
)
bool
{
func
(
a
*
RemoteAgent
)
SubmitWork
(
nonce
types
.
BlockNonce
,
mixDigest
,
hash
common
.
Hash
)
bool
{
a
.
mu
.
Lock
()
a
.
mu
.
Lock
()
defer
a
.
mu
.
Unlock
()
defer
a
.
mu
.
Unlock
()
...
...
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