From 49e848c36bc8e50b3ffaa34996e605466ed32c0d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Fri, 23 Sep 2022 08:06:06 -0700 Subject: [PATCH] Merge PR #999: Add ability to run all paths in config easil * Add ability to run all paths in config easily * PR review fixes * Fix tests and patch readme --- README.md | 2 ++ cmd/start.go | 40 +++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e507468a7..9ddde0483 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,8 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n ```shell $ rly paths list $ rly start [path] + # Optionally you can omit the `path` argument to start all configured paths + $ rly start ``` You will need to start a separate shell instance for each path you wish to relay over. diff --git a/cmd/start.go b/cmd/start.go index 5bacbaf8c..802bbce01 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -6,7 +6,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -38,25 +38,39 @@ func startCmd(a *appState) *cobra.Command { Use: "start path_name", Aliases: []string{"st"}, Short: "Start the listening relayer on a given path", - Args: withUsage(cobra.MinimumNArgs(1)), + Args: withUsage(cobra.MinimumNArgs(0)), Example: strings.TrimSpace(fmt.Sprintf(` -$ %s start demo-path -p events # to use event processor +$ %s start # start all configured paths +$ %s start demo-path # start the 'demo-path' path $ %s start demo-path --max-msgs 3 -$ %s start demo-path2 --max-tx-size 10`, appName, appName, appName)), +$ %s start demo-path2 --max-tx-size 10`, appName, appName, appName, appName)), RunE: func(cmd *cobra.Command, args []string) error { chains := make(map[string]*relayer.Chain) paths := make([]relayer.NamedPath, len(args)) - for i, pathName := range args { - path := a.Config.Paths.MustGet(pathName) - paths[i] = relayer.NamedPath{ - Name: pathName, - Path: path, - } + if len(args) > 0 { + for i, pathName := range args { + path := a.Config.Paths.MustGet(pathName) + paths[i] = relayer.NamedPath{ + Name: pathName, + Path: path, + } - // collect unique chain IDs - chains[path.Src.ChainID] = nil - chains[path.Dst.ChainID] = nil + // collect unique chain IDs + chains[path.Src.ChainID] = nil + chains[path.Dst.ChainID] = nil + } + } else { + for n, path := range a.Config.Paths { + paths = append(paths, relayer.NamedPath{ + Name: n, + Path: path, + }) + + // collect unique chain IDs + chains[path.Src.ChainID] = nil + chains[path.Dst.ChainID] = nil + } } chainIDs := make([]string, 0, len(chains))