@@ -22,6 +22,7 @@ import (
2222 "fmt"
2323 "os"
2424 "path"
25+ "strings"
2526 "sync/atomic"
2627 "time"
2728
@@ -379,13 +380,6 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
379380 beaconHeaders stat
380381 cliqueSnaps stat
381382
382- // Ancient store statistics
383- ancientHeadersSize common.StorageSize
384- ancientBodiesSize common.StorageSize
385- ancientReceiptsSize common.StorageSize
386- ancientTdsSize common.StorageSize
387- ancientHashesSize common.StorageSize
388-
389383 // Les statistic
390384 chtTrieNodes stat
391385 bloomTrieNodes stat
@@ -473,20 +467,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
473467 logged = time .Now ()
474468 }
475469 }
476- // Inspect append-only file store then.
477- ancientSizes := []* common.StorageSize {& ancientHeadersSize , & ancientBodiesSize , & ancientReceiptsSize , & ancientHashesSize , & ancientTdsSize }
478- for i , category := range []string {chainFreezerHeaderTable , chainFreezerBodiesTable , chainFreezerReceiptTable , chainFreezerHashTable , chainFreezerDifficultyTable } {
479- if size , err := db .AncientSize (category ); err == nil {
480- * ancientSizes [i ] += common .StorageSize (size )
481- total += common .StorageSize (size )
482- }
483- }
484- // Get number of ancient rows inside the freezer
485- ancients := counter (0 )
486- if count , err := db .Ancients (); err == nil {
487- ancients = counter (count )
488- }
489- // Display the database statistic.
470+ // Display the database statistic of key-value store.
490471 stats := [][]string {
491472 {"Key-Value store" , "Headers" , headers .Size (), headers .Count ()},
492473 {"Key-Value store" , "Bodies" , bodies .Size (), bodies .Count ()},
@@ -504,14 +485,25 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
504485 {"Key-Value store" , "Beacon sync headers" , beaconHeaders .Size (), beaconHeaders .Count ()},
505486 {"Key-Value store" , "Clique snapshots" , cliqueSnaps .Size (), cliqueSnaps .Count ()},
506487 {"Key-Value store" , "Singleton metadata" , metadata .Size (), metadata .Count ()},
507- {"Ancient store" , "Headers" , ancientHeadersSize .String (), ancients .String ()},
508- {"Ancient store" , "Bodies" , ancientBodiesSize .String (), ancients .String ()},
509- {"Ancient store" , "Receipt lists" , ancientReceiptsSize .String (), ancients .String ()},
510- {"Ancient store" , "Difficulties" , ancientTdsSize .String (), ancients .String ()},
511- {"Ancient store" , "Block number->hash" , ancientHashesSize .String (), ancients .String ()},
512488 {"Light client" , "CHT trie nodes" , chtTrieNodes .Size (), chtTrieNodes .Count ()},
513489 {"Light client" , "Bloom trie nodes" , bloomTrieNodes .Size (), bloomTrieNodes .Count ()},
514490 }
491+ // Inspect all registered append-only file store then.
492+ ancients , err := inspectFreezers (db )
493+ if err != nil {
494+ return err
495+ }
496+ for _ , ancient := range ancients {
497+ for _ , table := range ancient .sizes {
498+ stats = append (stats , []string {
499+ fmt .Sprintf ("Ancient store (%s)" , strings .Title (ancient .name )),
500+ strings .Title (table .name ),
501+ table .size .String (),
502+ fmt .Sprintf ("%d" , ancient .count ()),
503+ })
504+ }
505+ total += ancient .size ()
506+ }
515507 table := tablewriter .NewWriter (os .Stdout )
516508 table .SetHeader ([]string {"Database" , "Category" , "Size" , "Items" })
517509 table .SetFooter ([]string {"" , "Total" , total .String (), " " })
@@ -521,6 +513,5 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
521513 if unaccounted .size > 0 {
522514 log .Error ("Database contains unaccounted data" , "size" , unaccounted .size , "count" , unaccounted .count )
523515 }
524-
525516 return nil
526517}
0 commit comments