Skip to content

Commit

Permalink
Add schema_version to output of db info command (#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan authored Dec 11, 2024
1 parent 60e8cc9 commit 91d0f8e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/juno/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/db"
"github.com/NethermindEth/juno/db/pebble"
"github.com/NethermindEth/juno/migration"
"github.com/NethermindEth/juno/utils"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
Expand All @@ -21,6 +22,7 @@ const (

type DBInfo struct {
Network string `json:"network"`
SchemaVersion uint64 `json:"schema_version"`
ChainHeight uint64 `json:"chain_height"`
LatestBlockHash *felt.Felt `json:"latest_block_hash"`
LatestStateRoot *felt.Felt `json:"latest_state_root"`
Expand Down Expand Up @@ -84,7 +86,7 @@ func dbInfo(cmd *cobra.Command, args []string) error {
defer database.Close()

chain := blockchain.New(database, nil)
info := DBInfo{}
var info DBInfo

// Get the latest block information
headBlock, err := chain.Head()
Expand All @@ -97,6 +99,12 @@ func dbInfo(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to get the state update: %v", err)
}

schemaMeta, err := migration.SchemaMetadata(database)
if err != nil {
return fmt.Errorf("failed to get schema metadata: %v", err)
}

info.SchemaVersion = schemaMeta.Version
info.Network = getNetwork(headBlock, stateUpdate.StateDiff)
info.ChainHeight = headBlock.Number
info.LatestBlockHash = headBlock.Hash
Expand Down

0 comments on commit 91d0f8e

Please sign in to comment.