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
3996bc1a
Unverified
Commit
3996bc1a
authored
Apr 08, 2019
by
Péter Szilágyi
Committed by
GitHub
Apr 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19411 from holiman/uncle_abort_early
consensus,core: shortcut uncle validation
parents
2a8a07c2
d763b49a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
consensus.go
consensus/ethash/consensus.go
+3
-0
block.go
core/types/block.go
+4
-1
block_test.go
core/types/block_test.go
+16
-0
No files found.
consensus/ethash/consensus.go
View file @
3996bc1a
...
...
@@ -191,6 +191,9 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo
if
len
(
block
.
Uncles
())
>
maxUncles
{
return
errTooManyUncles
}
if
len
(
block
.
Uncles
())
==
0
{
return
nil
}
// Gather the set of past uncles and ancestors
uncles
,
ancestors
:=
mapset
.
NewSet
(),
make
(
map
[
common
.
Hash
]
*
types
.
Header
)
...
...
core/types/block.go
View file @
3996bc1a
...
...
@@ -34,7 +34,7 @@ import (
var
(
EmptyRootHash
=
DeriveSha
(
Transactions
{})
EmptyUncleHash
=
CalcUncleHash
(
nil
)
EmptyUncleHash
=
rlpHash
([]
*
Header
(
nil
)
)
)
// A BlockNonce is a 64-bit hash which proves (combined with the
...
...
@@ -324,6 +324,9 @@ func (c *writeCounter) Write(b []byte) (int, error) {
}
func
CalcUncleHash
(
uncles
[]
*
Header
)
common
.
Hash
{
if
len
(
uncles
)
==
0
{
return
EmptyUncleHash
}
return
rlpHash
(
uncles
)
}
...
...
core/types/block_test.go
View file @
3996bc1a
...
...
@@ -68,3 +68,19 @@ func TestBlockEncoding(t *testing.T) {
t
.
Errorf
(
"encoded block mismatch:
\n
got: %x
\n
want: %x"
,
ourBlockEnc
,
blockEnc
)
}
}
func
TestUncleHash
(
t
*
testing
.
T
)
{
uncles
:=
make
([]
*
Header
,
0
)
h
:=
CalcUncleHash
(
uncles
)
exp
:=
common
.
HexToHash
(
"1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
)
if
h
!=
exp
{
t
.
Fatalf
(
"empty uncle hash is wrong, got %x != %x"
,
h
,
exp
)
}
}
func
BenchmarkUncleHash
(
b
*
testing
.
B
)
{
uncles
:=
make
([]
*
Header
,
0
)
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
CalcUncleHash
(
uncles
)
}
}
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