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
ec3432bc
Unverified
Commit
ec3432bc
authored
Feb 04, 2019
by
Martin Holst Swende
Committed by
GitHub
Feb 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix error in block iterator (#18986)
parent
bb7c786b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
11 deletions
+3
-11
blockchain.go
core/blockchain.go
+3
-3
blockchain_insert.go
core/blockchain_insert.go
+0
-8
No files found.
core/blockchain.go
View file @
ec3432bc
...
...
@@ -1143,7 +1143,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
switch
{
// First block is pruned, insert as sidechain and reorg only if TD grows enough
case
err
==
consensus
.
ErrPrunedAncestor
:
return
bc
.
insertSidechain
(
it
)
return
bc
.
insertSidechain
(
block
,
it
)
// 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
()))
:
...
...
@@ -1285,7 +1285,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
//
// The method writes all (header-and-body-valid) blocks to disk, then tries to
// switch over to the new chain if the TD exceeded the current chain.
func
(
bc
*
BlockChain
)
insertSidechain
(
it
*
insertIterator
)
(
int
,
[]
interface
{},
[]
*
types
.
Log
,
error
)
{
func
(
bc
*
BlockChain
)
insertSidechain
(
block
*
types
.
Block
,
it
*
insertIterator
)
(
int
,
[]
interface
{},
[]
*
types
.
Log
,
error
)
{
var
(
externTd
*
big
.
Int
current
=
bc
.
CurrentBlock
()
...
...
@@ -1294,7 +1294,7 @@ func (bc *BlockChain) insertSidechain(it *insertIterator) (int, []interface{}, [
// Since we don't import them here, we expect ErrUnknownAncestor for the remaining
// ones. Any other errors means that the block is invalid, and should not be written
// to disk.
block
,
err
:=
it
.
current
(),
consensus
.
ErrPrunedAncestor
err
:=
consensus
.
ErrPrunedAncestor
for
;
block
!=
nil
&&
(
err
==
consensus
.
ErrPrunedAncestor
);
block
,
err
=
it
.
next
()
{
// Check the canonical state root for that number
if
number
:=
block
.
NumberU64
();
current
.
NumberU64
()
>=
number
{
...
...
core/blockchain_insert.go
View file @
ec3432bc
...
...
@@ -111,14 +111,6 @@ func (it *insertIterator) next() (*types.Block, error) {
return
it
.
chain
[
it
.
index
],
it
.
validator
.
ValidateBody
(
it
.
chain
[
it
.
index
])
}
// current returns the current block that's being processed.
func
(
it
*
insertIterator
)
current
()
*
types
.
Block
{
if
it
.
index
<
0
||
it
.
index
+
1
>=
len
(
it
.
chain
)
{
return
nil
}
return
it
.
chain
[
it
.
index
]
}
// previous returns the previous block was being processed, or nil
func
(
it
*
insertIterator
)
previous
()
*
types
.
Block
{
if
it
.
index
<
1
{
...
...
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