Skip to content

Commit

Permalink
Refactor path generation and status
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzampolin committed Nov 4, 2020
1 parent 07d45b6 commit 650bb76
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 296 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ lint:

.PHONY: install build lint coverage clean

# TODO: Port reproducable build scripts from gaia for relayer
# TODO: Full tested and working releases
33 changes: 28 additions & 5 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ var (
flagHash = "hash"
flagURL = "url"
flagForce = "force"
flagVersion = "version"
flagStrategy = "strategy"
flagTimeout = "timeout"
flagConfig = "config"
flagJSON = "json"
flagYAML = "yaml"
flagFile = "file"
flagPort = "port"
flagPath = "path"
flagListenAddr = "listen"
flagTx = "no-tx"
Expand Down Expand Up @@ -78,6 +81,14 @@ func yamlFlag(cmd *cobra.Command) *cobra.Command {
return cmd
}

func portFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().StringP(flagPort, "p", "transfer", "port to use when generating path")
if err := viper.BindPFlag(flagPort, cmd.Flags().Lookup(flagPort)); err != nil {
panic(err)
}
return cmd
}

func orderFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().BoolP(flagOrder, "o", true, "create an unordered channel")
if err := viper.BindPFlag(flagOrder, cmd.Flags().Lookup(flagOrder)); err != nil {
Expand Down Expand Up @@ -124,10 +135,14 @@ func pathFlag(cmd *cobra.Command) *cobra.Command {
return cmd
}

// TODO: add ability to set timeout height and time from flags
// Should be relative to current time and block height
// --timeout-height-offset=1000
// --timeout-time-offset=2h
func pathStrategy(cmd *cobra.Command) *cobra.Command {
cmd.Flags().StringP(flagStrategy, "s", "naive", "specify strategy of path to generate")
if err := viper.BindPFlag(flagStrategy, cmd.Flags().Lookup(flagStrategy)); err != nil {
panic(err)
}
return cmd
}

func timeoutFlags(cmd *cobra.Command) *cobra.Command {
cmd.Flags().Uint64P(flagTimeoutHeightOffset, "y", 0, "set timeout height offset for ")
cmd.Flags().DurationP(flagTimeoutTimeOffset, "c", time.Duration(0), "specify the path to relay over")
Expand Down Expand Up @@ -164,6 +179,14 @@ func timeoutFlag(cmd *cobra.Command) *cobra.Command {
return cmd
}

func versionFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().StringP(flagVersion, "v", "ics20-1", "version of channel to create")
if err := viper.BindPFlag(flagVersion, cmd.Flags().Lookup(flagVersion)); err != nil {
panic(err)
}
return cmd
}

func forceFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().BoolP(flagForce, "f", false, "option to force non-standard behavior such as initialization of light client from configured chain or generation of new path") //nolint:lll
if err := viper.BindPFlag(flagForce, cmd.Flags().Lookup(flagForce)); err != nil {
Expand All @@ -189,7 +212,7 @@ func urlFlag(cmd *cobra.Command) *cobra.Command {
}

func strategyFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().StringP(flagMaxTxSize, "s", "2", "maximum size (in MB) of the messages in a relay transaction")
cmd.Flags().StringP(flagMaxTxSize, "s", "2", "strategy of path to generate of the messages in a relay transaction")
cmd.Flags().StringP(flagMaxMsgLength, "l", "5", "maximum number of messages in a relay transaction")
if err := viper.BindPFlag(flagMaxTxSize, cmd.Flags().Lookup(flagMaxTxSize)); err != nil {
panic(err)
Expand Down
1 change: 0 additions & 1 deletion cmd/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func updateLightCmd() *cobra.Command {
return err
}

// TODO: more fun printing here like time deltas?
fmt.Printf("Updated light client for %s from height %d -> height %d\n", args[0], bh.Header.Height, ah.Header.Height)
return nil
},
Expand Down
Loading

0 comments on commit 650bb76

Please sign in to comment.