Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions core/rawdb/ancient_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ type tableSize struct {

// freezerInfo contains the basic information of the freezer.
type freezerInfo struct {
name string // The identifier of freezer
head uint64 // The number of last stored item in the freezer
tail uint64 // The number of first stored item in the freezer
sizes []tableSize // The storage size per table
}

// count returns the number of stored items in the freezer.
func (info *freezerInfo) count() uint64 {
return info.head - info.tail + 1
name string // The identifier of freezer
ancients uint64 // The total number of stored items in the freezer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed, please remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed, please remove it

corrected

head uint64 // The number of last stored item in the freezer, valid only if ancients > 0
tail uint64 // The number of first stored item in the freezer
count uint64 // The number of stored items in the freezer
sizes []tableSize // The storage size per table
}

// size returns the storage size of the entire freezer.
Expand All @@ -65,14 +62,24 @@ func inspect(name string, order map[string]freezerTableConfig, reader ethdb.Anci
if err != nil {
return freezerInfo{}, err
}
info.head = ancients - 1
info.ancients = ancients
if ancients > 0 {
info.head = ancients - 1
} else {
info.head = 0
}

// Retrieve the number of first stored item
tail, err := reader.Tail()
if err != nil {
return freezerInfo{}, err
}
info.tail = tail
if ancients == 0 {
info.count = 0
} else {
info.count = info.head - info.tail + 1
}
return info, nil
}

Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
fmt.Sprintf("Ancient store (%s)", strings.Title(ancient.name)),
strings.Title(table.name),
table.size.String(),
fmt.Sprintf("%d", ancient.count()),
fmt.Sprintf("%d", ancient.count),
})
}
total.Add(uint64(ancient.size()))
Expand Down