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
5a88a7cf
Unverified
Commit
5a88a7cf
authored
Aug 05, 2020
by
Robert Zaremba
Committed by
GitHub
Aug 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use errors.Is for consensus errors check (#21095)
parent
1d25039f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
blockchain.go
core/blockchain.go
+6
-6
No files found.
core/blockchain.go
View file @
5a88a7cf
...
@@ -1706,13 +1706,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
...
@@ -1706,13 +1706,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
}
}
switch
{
switch
{
// First block is pruned, insert as sidechain and reorg only if TD grows enough
// First block is pruned, insert as sidechain and reorg only if TD grows enough
case
err
==
consensus
.
ErrPrunedAncestor
:
case
err
ors
.
Is
(
err
,
consensus
.
ErrPrunedAncestor
)
:
log
.
Debug
(
"Pruned ancestor, inserting as sidechain"
,
"number"
,
block
.
Number
(),
"hash"
,
block
.
Hash
())
log
.
Debug
(
"Pruned ancestor, inserting as sidechain"
,
"number"
,
block
.
Number
(),
"hash"
,
block
.
Hash
())
return
bc
.
insertSideChain
(
block
,
it
)
return
bc
.
insertSideChain
(
block
,
it
)
// First block is future, shove it (and all children) to the future queue (unknown ancestor)
// First block is future, shove it (and all children) to the future queue (unknown ancestor)
case
err
==
consensus
.
ErrFutureBlock
||
(
err
==
consensus
.
ErrUnknownAncestor
&&
bc
.
futureBlocks
.
Contains
(
it
.
first
()
.
ParentHash
()))
:
case
err
ors
.
Is
(
err
,
consensus
.
ErrFutureBlock
)
||
(
errors
.
Is
(
err
,
consensus
.
ErrUnknownAncestor
)
&&
bc
.
futureBlocks
.
Contains
(
it
.
first
()
.
ParentHash
()))
:
for
block
!=
nil
&&
(
it
.
index
==
0
||
err
==
consensus
.
ErrUnknownAncestor
)
{
for
block
!=
nil
&&
(
it
.
index
==
0
||
err
ors
.
Is
(
err
,
consensus
.
ErrUnknownAncestor
)
)
{
log
.
Debug
(
"Future block, postponing import"
,
"number"
,
block
.
Number
(),
"hash"
,
block
.
Hash
())
log
.
Debug
(
"Future block, postponing import"
,
"number"
,
block
.
Number
(),
"hash"
,
block
.
Hash
())
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
return
it
.
index
,
err
return
it
.
index
,
err
...
@@ -1895,13 +1895,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
...
@@ -1895,13 +1895,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
stats
.
report
(
chain
,
it
.
index
,
dirty
)
stats
.
report
(
chain
,
it
.
index
,
dirty
)
}
}
// Any blocks remaining here? The only ones we care about are the future ones
// Any blocks remaining here? The only ones we care about are the future ones
if
block
!=
nil
&&
err
==
consensus
.
ErrFutureBlock
{
if
block
!=
nil
&&
err
ors
.
Is
(
err
,
consensus
.
ErrFutureBlock
)
{
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
return
it
.
index
,
err
return
it
.
index
,
err
}
}
block
,
err
=
it
.
next
()
block
,
err
=
it
.
next
()
for
;
block
!=
nil
&&
err
==
consensus
.
ErrUnknownAncestor
;
block
,
err
=
it
.
next
()
{
for
;
block
!=
nil
&&
err
ors
.
Is
(
err
,
consensus
.
ErrUnknownAncestor
)
;
block
,
err
=
it
.
next
()
{
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
if
err
:=
bc
.
addFutureBlock
(
block
);
err
!=
nil
{
return
it
.
index
,
err
return
it
.
index
,
err
}
}
...
@@ -1929,7 +1929,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i
...
@@ -1929,7 +1929,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i
// ones. Any other errors means that the block is invalid, and should not be written
// ones. Any other errors means that the block is invalid, and should not be written
// to disk.
// to disk.
err
:=
consensus
.
ErrPrunedAncestor
err
:=
consensus
.
ErrPrunedAncestor
for
;
block
!=
nil
&&
(
err
==
consensus
.
ErrPrunedAncestor
);
block
,
err
=
it
.
next
()
{
for
;
block
!=
nil
&&
errors
.
Is
(
err
,
consensus
.
ErrPrunedAncestor
);
block
,
err
=
it
.
next
()
{
// Check the canonical state root for that number
// Check the canonical state root for that number
if
number
:=
block
.
NumberU64
();
current
.
NumberU64
()
>=
number
{
if
number
:=
block
.
NumberU64
();
current
.
NumberU64
()
>=
number
{
canonical
:=
bc
.
GetBlockByNumber
(
number
)
canonical
:=
bc
.
GetBlockByNumber
(
number
)
...
...
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