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
add1bff1
Unverified
Commit
add1bff1
authored
Nov 25, 2022
by
rjl493456442
Committed by
GitHub
Nov 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/rawdb: fix freezer validation (#26251)
* core/rawdb: fix freezer validation * core/rawdb: address comment
parent
c5dc61c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
freezer.go
core/rawdb/freezer.go
+15
-10
No files found.
core/rawdb/freezer.go
View file @
add1bff1
...
...
@@ -318,30 +318,35 @@ func (f *Freezer) Sync() error {
return
nil
}
// validate checks that every table has the same
length
.
// validate checks that every table has the same
boundary
.
// Used instead of `repair` in readonly mode.
func
(
f
*
Freezer
)
validate
()
error
{
if
len
(
f
.
tables
)
==
0
{
return
nil
}
var
(
length
uint64
name
string
head
uint64
tail
uint64
name
string
)
// Hack to get
length
of any table
// Hack to get
boundary
of any table
for
kind
,
table
:=
range
f
.
tables
{
length
=
atomic
.
LoadUint64
(
&
table
.
items
)
head
=
atomic
.
LoadUint64
(
&
table
.
items
)
tail
=
atomic
.
LoadUint64
(
&
table
.
itemHidden
)
name
=
kind
break
}
// Now check every table against th
at length
// Now check every table against th
ose boundaries.
for
kind
,
table
:=
range
f
.
tables
{
items
:=
atomic
.
LoadUint64
(
&
table
.
items
)
if
length
!=
items
{
return
fmt
.
Errorf
(
"freezer tables %s and %s have differing lengths: %d != %d"
,
kind
,
name
,
items
,
length
)
if
head
!=
atomic
.
LoadUint64
(
&
table
.
items
)
{
return
fmt
.
Errorf
(
"freezer tables %s and %s have differing head: %d != %d"
,
kind
,
name
,
atomic
.
LoadUint64
(
&
table
.
items
),
head
)
}
if
tail
!=
atomic
.
LoadUint64
(
&
table
.
itemHidden
)
{
return
fmt
.
Errorf
(
"freezer tables %s and %s have differing tail: %d != %d"
,
kind
,
name
,
atomic
.
LoadUint64
(
&
table
.
itemHidden
),
tail
)
}
}
atomic
.
StoreUint64
(
&
f
.
frozen
,
length
)
atomic
.
StoreUint64
(
&
f
.
frozen
,
head
)
atomic
.
StoreUint64
(
&
f
.
tail
,
tail
)
return
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