Skip to content

Commit

Permalink
Add schema_version to output of db info command
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan committed Dec 7, 2024
1 parent 2a82a59 commit 2c1ffe6
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 @@ -13,6 +13,7 @@ import (
"github.com/NethermindEth/juno/utils"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"github.com/NethermindEth/juno/migration"
)

const (
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)
}

Check warning on line 105 in cmd/juno/dbcmd.go

View check run for this annotation

Codecov / codecov/patch

cmd/juno/dbcmd.go#L104-L105

Added lines #L104 - L105 were not covered by tests
info.SchemaVersion = schemaMeta.Version

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

0 comments on commit 2c1ffe6

Please sign in to comment.