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
b748709a
Unverified
Commit
b748709a
authored
Jan 12, 2023
by
rjl493456442
Committed by
GitHub
Jan 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: fix cornercase when clean stale beacon headers (#26441)
parent
6f858fa8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
skeleton.go
eth/downloader/skeleton.go
+8
-5
No files found.
eth/downloader/skeleton.go
View file @
b748709a
...
...
@@ -1102,6 +1102,7 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
var
(
start
=
s
.
progress
.
Subchains
[
0
]
.
Tail
// start deleting from the first known header
end
=
number
// delete until the requested threshold
batch
=
s
.
db
.
NewBatch
()
)
s
.
progress
.
Subchains
[
0
]
.
Tail
=
number
s
.
progress
.
Subchains
[
0
]
.
Next
=
filled
.
ParentHash
...
...
@@ -1111,16 +1112,13 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
// subchain forward to keep tracking the node's block imports
end
=
s
.
progress
.
Subchains
[
0
]
.
Head
+
1
// delete the entire original range, including the head
s
.
progress
.
Subchains
[
0
]
.
Head
=
number
// assign a new head (tail is already assigned to this)
}
// Execute the trimming and the potential rewiring of the progress
batch
:=
s
.
db
.
NewBatch
()
if
end
!=
number
{
// The entire original skeleton chain was deleted and a new one
// defined. Make sure the new single-header chain gets pushed to
// disk to keep internal state consistent.
rawdb
.
WriteSkeletonHeader
(
batch
,
filled
)
}
// Execute the trimming and the potential rewiring of the progress
s
.
saveSyncStatus
(
batch
)
for
n
:=
start
;
n
<
end
;
n
++
{
// If the batch grew too big, flush it and continue with a new batch.
...
...
@@ -1176,8 +1174,13 @@ func (s *skeleton) Bounds() (head *types.Header, tail *types.Header, err error)
return
nil
,
nil
,
err
}
head
=
rawdb
.
ReadSkeletonHeader
(
s
.
db
,
progress
.
Subchains
[
0
]
.
Head
)
if
head
==
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"head skeleton header %d is missing"
,
progress
.
Subchains
[
0
]
.
Head
)
}
tail
=
rawdb
.
ReadSkeletonHeader
(
s
.
db
,
progress
.
Subchains
[
0
]
.
Tail
)
if
tail
==
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"tail skeleton header %d is missing"
,
progress
.
Subchains
[
0
]
.
Tail
)
}
return
head
,
tail
,
nil
}
...
...
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