cmd/geth: add db-command to inspect freezer index (#22633)
This PR makes it easier to inspect the freezer index, which could be useful to investigate things like #22111
This commit is contained in:
committed by
GitHub
parent
6c27d8f996
commit
271e5b7fc9
@ -636,25 +636,24 @@ func (t *freezerTable) Sync() error {
|
||||
return t.head.Sync()
|
||||
}
|
||||
|
||||
// printIndex is a debug print utility function for testing
|
||||
func (t *freezerTable) printIndex() {
|
||||
// DumpIndex is a debug print utility function, mainly for testing. It can also
|
||||
// be used to analyse a live freezer table index.
|
||||
func (t *freezerTable) DumpIndex(start, stop int64) {
|
||||
buf := make([]byte, indexEntrySize)
|
||||
|
||||
fmt.Printf("|-----------------|\n")
|
||||
fmt.Printf("| fileno | offset |\n")
|
||||
fmt.Printf("|--------+--------|\n")
|
||||
fmt.Printf("| number | fileno | offset |\n")
|
||||
fmt.Printf("|--------|--------|--------|\n")
|
||||
|
||||
for i := uint64(0); ; i++ {
|
||||
for i := uint64(start); ; i++ {
|
||||
if _, err := t.index.ReadAt(buf, int64(i*indexEntrySize)); err != nil {
|
||||
break
|
||||
}
|
||||
var entry indexEntry
|
||||
entry.unmarshalBinary(buf)
|
||||
fmt.Printf("| %03d | %03d | \n", entry.filenum, entry.offset)
|
||||
if i > 100 {
|
||||
fmt.Printf(" ... \n")
|
||||
fmt.Printf("| %03d | %03d | %03d | \n", i, entry.filenum, entry.offset)
|
||||
if stop > 0 && i >= uint64(stop) {
|
||||
break
|
||||
}
|
||||
}
|
||||
fmt.Printf("|-----------------|\n")
|
||||
fmt.Printf("|--------------------------|\n")
|
||||
}
|
||||
|
Reference in New Issue
Block a user