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
ad990895
Commit
ad990895
authored
May 16, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/0.9.21.1' into develop
parents
61e8296b
ad7b0efb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
27 deletions
+35
-27
main.go
cmd/geth/main.go
+1
-1
block_processor.go
core/block_processor.go
+8
-8
downloader.go
eth/downloader/downloader.go
+2
-2
agent.go
miner/agent.go
+24
-16
No files found.
cmd/geth/main.go
View file @
ad990895
...
@@ -50,7 +50,7 @@ import _ "net/http/pprof"
...
@@ -50,7 +50,7 @@ import _ "net/http/pprof"
const
(
const
(
ClientIdentifier
=
"Geth"
ClientIdentifier
=
"Geth"
Version
=
"0.9.21"
Version
=
"0.9.21
.1
"
)
)
var
(
var
(
...
...
core/block_processor.go
View file @
ad990895
...
@@ -343,23 +343,23 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
...
@@ -343,23 +343,23 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
uncles
.
Add
(
block
.
Hash
())
uncles
.
Add
(
block
.
Hash
())
for
i
,
uncle
:=
range
block
.
Uncles
()
{
for
i
,
uncle
:=
range
block
.
Uncles
()
{
if
uncles
.
Has
(
uncle
.
Hash
())
{
hash
:=
uncle
.
Hash
()
if
uncles
.
Has
(
hash
)
{
// Error not unique
// Error not unique
return
UncleError
(
"uncle[%d]
not unique"
,
i
)
return
UncleError
(
"uncle[%d]
(%x) not unique"
,
i
,
hash
[
:
4
]
)
}
}
uncles
.
Add
(
hash
)
uncles
.
Add
(
uncle
.
Hash
())
if
ancestors
.
Has
(
hash
)
{
return
UncleError
(
"uncle[%d](%x) is ancestor"
,
i
,
hash
[
:
4
])
if
ancestors
.
Has
(
uncle
.
Hash
())
{
return
UncleError
(
"uncle[%d] is ancestor"
,
i
)
}
}
if
!
ancestors
.
Has
(
uncle
.
ParentHash
)
{
if
!
ancestors
.
Has
(
uncle
.
ParentHash
)
{
return
UncleError
(
"uncle[%d]
's parent unknown (%x)"
,
i
,
uncle
.
ParentHash
[
0
:
4
])
return
UncleError
(
"uncle[%d]
(%x)'s parent unknown (%x)"
,
i
,
hash
[
:
4
]
,
uncle
.
ParentHash
[
0
:
4
])
}
}
if
err
:=
sm
.
ValidateHeader
(
uncle
,
ancestorHeaders
[
uncle
.
ParentHash
]);
err
!=
nil
{
if
err
:=
sm
.
ValidateHeader
(
uncle
,
ancestorHeaders
[
uncle
.
ParentHash
]);
err
!=
nil
{
return
ValidationError
(
fmt
.
Sprintf
(
"uncle[%d](%x) header invalid: %v"
,
i
,
uncle
.
Hash
()
.
Bytes
()
[
:
4
],
err
))
return
ValidationError
(
fmt
.
Sprintf
(
"uncle[%d](%x) header invalid: %v"
,
i
,
hash
[
:
4
],
err
))
}
}
}
}
...
...
eth/downloader/downloader.go
View file @
ad990895
...
@@ -145,8 +145,6 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
...
@@ -145,8 +145,6 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Block synchronisation started"
)
glog
.
V
(
logger
.
Info
)
.
Infoln
(
"Block synchronisation started"
)
}
}
d
.
mux
.
Post
(
StartEvent
{})
// Create cancel channel for aborting mid-flight
// Create cancel channel for aborting mid-flight
d
.
cancelLock
.
Lock
()
d
.
cancelLock
.
Lock
()
d
.
cancelCh
=
make
(
chan
struct
{})
d
.
cancelCh
=
make
(
chan
struct
{})
...
@@ -166,6 +164,7 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
...
@@ -166,6 +164,7 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
if
p
==
nil
{
if
p
==
nil
{
return
errUnknownPeer
return
errUnknownPeer
}
}
return
d
.
syncWithPeer
(
p
,
hash
)
return
d
.
syncWithPeer
(
p
,
hash
)
}
}
...
@@ -181,6 +180,7 @@ func (d *Downloader) Has(hash common.Hash) bool {
...
@@ -181,6 +180,7 @@ func (d *Downloader) Has(hash common.Hash) bool {
// syncWithPeer starts a block synchronization based on the hash chain from the
// syncWithPeer starts a block synchronization based on the hash chain from the
// specified peer and head hash.
// specified peer and head hash.
func
(
d
*
Downloader
)
syncWithPeer
(
p
*
peer
,
hash
common
.
Hash
)
(
err
error
)
{
func
(
d
*
Downloader
)
syncWithPeer
(
p
*
peer
,
hash
common
.
Hash
)
(
err
error
)
{
d
.
mux
.
Post
(
StartEvent
{})
defer
func
()
{
defer
func
()
{
// reset on error
// reset on error
if
err
!=
nil
{
if
err
!=
nil
{
...
...
miner/agent.go
View file @
ad990895
...
@@ -11,8 +11,9 @@ import (
...
@@ -11,8 +11,9 @@ import (
)
)
type
CpuAgent
struct
{
type
CpuAgent
struct
{
chMu
sync
.
Mutex
mu
sync
.
Mutex
c
chan
*
types
.
Block
workCh
chan
*
types
.
Block
quit
chan
struct
{}
quit
chan
struct
{}
quitCurrentOp
chan
struct
{}
quitCurrentOp
chan
struct
{}
returnCh
chan
<-
*
types
.
Block
returnCh
chan
<-
*
types
.
Block
...
@@ -30,19 +31,27 @@ func NewCpuAgent(index int, pow pow.PoW) *CpuAgent {
...
@@ -30,19 +31,27 @@ func NewCpuAgent(index int, pow pow.PoW) *CpuAgent {
return
miner
return
miner
}
}
func
(
self
*
CpuAgent
)
Work
()
chan
<-
*
types
.
Block
{
return
self
.
c
}
func
(
self
*
CpuAgent
)
Work
()
chan
<-
*
types
.
Block
{
return
self
.
workCh
}
func
(
self
*
CpuAgent
)
Pow
()
pow
.
PoW
{
return
self
.
pow
}
func
(
self
*
CpuAgent
)
Pow
()
pow
.
PoW
{
return
self
.
pow
}
func
(
self
*
CpuAgent
)
SetReturnCh
(
ch
chan
<-
*
types
.
Block
)
{
self
.
returnCh
=
ch
}
func
(
self
*
CpuAgent
)
SetReturnCh
(
ch
chan
<-
*
types
.
Block
)
{
self
.
returnCh
=
ch
}
func
(
self
*
CpuAgent
)
Stop
()
{
func
(
self
*
CpuAgent
)
Stop
()
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
close
(
self
.
quit
)
close
(
self
.
quit
)
close
(
self
.
quitCurrentOp
)
close
(
self
.
quitCurrentOp
)
}
}
func
(
self
*
CpuAgent
)
Start
()
{
func
(
self
*
CpuAgent
)
Start
()
{
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
self
.
quit
=
make
(
chan
struct
{})
self
.
quit
=
make
(
chan
struct
{})
self
.
quitCurrentOp
=
make
(
chan
struct
{},
1
)
// creating current op ch makes sure we're not closing a nil ch
self
.
c
=
make
(
chan
*
types
.
Block
,
1
)
// later on
self
.
quitCurrentOp
=
make
(
chan
struct
{})
self
.
workCh
=
make
(
chan
*
types
.
Block
,
1
)
go
self
.
update
()
go
self
.
update
()
}
}
...
@@ -51,10 +60,10 @@ func (self *CpuAgent) update() {
...
@@ -51,10 +60,10 @@ func (self *CpuAgent) update() {
out
:
out
:
for
{
for
{
select
{
select
{
case
block
:=
<-
self
.
c
:
case
block
:=
<-
self
.
workCh
:
self
.
chM
u
.
Lock
()
self
.
m
u
.
Lock
()
self
.
quitCurrentOp
<-
struct
{}{}
close
(
self
.
quitCurrentOp
)
self
.
chM
u
.
Unlock
()
self
.
m
u
.
Unlock
()
go
self
.
mine
(
block
)
go
self
.
mine
(
block
)
case
<-
self
.
quit
:
case
<-
self
.
quit
:
...
@@ -62,14 +71,13 @@ out:
...
@@ -62,14 +71,13 @@ out:
}
}
}
}
//close(self.quitCurrentOp)
done
:
done
:
// Empty channel
// Empty
work
channel
for
{
for
{
select
{
select
{
case
<-
self
.
c
:
case
<-
self
.
workCh
:
default
:
default
:
close
(
self
.
c
)
close
(
self
.
workCh
)
break
done
break
done
}
}
...
@@ -80,9 +88,9 @@ func (self *CpuAgent) mine(block *types.Block) {
...
@@ -80,9 +88,9 @@ func (self *CpuAgent) mine(block *types.Block) {
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"(re)started agent[%d]. mining...
\n
"
,
self
.
index
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"(re)started agent[%d]. mining...
\n
"
,
self
.
index
)
// Reset the channel
// Reset the channel
self
.
chM
u
.
Lock
()
self
.
m
u
.
Lock
()
self
.
quitCurrentOp
=
make
(
chan
struct
{}
,
1
)
self
.
quitCurrentOp
=
make
(
chan
struct
{})
self
.
chM
u
.
Unlock
()
self
.
m
u
.
Unlock
()
// Mine
// Mine
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
block
,
self
.
quitCurrentOp
)
nonce
,
mixDigest
:=
self
.
pow
.
Search
(
block
,
self
.
quitCurrentOp
)
...
...
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