Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Oct 28, 2024
1 parent c48172d commit 9addef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions server/v2/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,18 @@ var appBuildingCommands = [][]string{
{"genesis", "export"},
}

// IsAppRequired returns true if the command requires a full app to be built
// by recursively checking the `Use` property of `cmd` and its parents.
// By default, the commands in `appBuildingCommands` are considered to require
// a full app to be built. They are "start" and "genesis export".
// Additional commands can be passed as arguments to this function.
// IsAppRequired determines if a command requires a full application to be built by
// recursively checking the command hierarchy against known command paths.
//
// The function works by:
// 1. Combining default appBuildingCommands with additional required commands
// 2. Building command paths by traversing up the command tree
// 3. Checking if any known command path matches the current command path
//
// Time Complexity: O(d * p) where d is command depth and p is number of paths
// Space Complexity: O(p) where p is total number of command paths
func IsAppRequired(cmd *cobra.Command, required ...[]string) bool {
m := map[string]bool{}
m := make(map[string]bool)
cmds := append(appBuildingCommands, required...)
for _, c := range cmds {
slices.Reverse(c)
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func initRootCmd[T transaction.Tx](

rootCmd.AddCommand(
genutilcli.InitCmd(deps.moduleManager),
genesisCommand(deps.moduleManager, deps.simApp),
NewTestnetCmd(deps.moduleManager),
debug.Cmd(),
confixcmd.ConfigCommand(),
NewTestnetCmd(deps.moduleManager),
// add keybase, auxiliary RPC, query, genesis, and tx child commands
genesisCommand(deps.moduleManager, deps.simApp),
queryCommand(),
txCommand(),
keys.Commands(),
Expand Down

0 comments on commit 9addef4

Please sign in to comment.