Skip to content

Commit

Permalink
Merge PR #999: Add ability to run all paths in config easil
Browse files Browse the repository at this point in the history
* Add ability to run all paths in config easily

* PR review fixes

* Fix tests and patch readme
  • Loading branch information
jackzampolin authored and agouin committed Nov 15, 2022
1 parent 64e62c2 commit 49e848c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 27 additions & 13 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 49e848c

Please sign in to comment.