cmd/blockstore/yaml: print first and last slot
This commit is contained in:
parent
22cd485d9c
commit
3e87b452bd
|
@ -51,6 +51,7 @@ func run(c *cobra.Command, args []string) {
|
|||
defer db.Close()
|
||||
|
||||
printRoot(db)
|
||||
printMetaRange(db)
|
||||
|
||||
if *flagSlots == "all" {
|
||||
dumpAllSlots(db)
|
||||
|
@ -91,6 +92,27 @@ func printRoot(db *blockstore.DB) {
|
|||
fmt.Println("root:", root)
|
||||
}
|
||||
|
||||
func printMetaRange(db *blockstore.DB) {
|
||||
iter := db.DB.NewIteratorCF(grocksdb.NewDefaultReadOptions(), db.CfMeta)
|
||||
defer iter.Close()
|
||||
|
||||
iter.SeekToFirst()
|
||||
if iter.Valid() {
|
||||
slot, ok := blockstore.ParseSlotKey(iter.Key().Data())
|
||||
if ok {
|
||||
fmt.Printf("first_slot: %d\n", slot)
|
||||
}
|
||||
}
|
||||
|
||||
iter.SeekToLast()
|
||||
if iter.Valid() {
|
||||
slot, ok := blockstore.ParseSlotKey(iter.Key().Data())
|
||||
if ok {
|
||||
fmt.Printf("last_slot: %d\n", slot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dumpAllSlots(db *blockstore.DB) {
|
||||
iter := db.DB.NewIteratorCF(grocksdb.NewDefaultReadOptions(), db.CfMeta)
|
||||
iter.SeekToFirst()
|
||||
|
|
Loading…
Reference in New Issue