Skip to content

Commit

Permalink
address Chris' comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Kunze committed Nov 27, 2018
1 parent 14154f7 commit 7cf5da2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion client/tx/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func SearchTxCmd(cdc *codec.Codec) *cobra.Command {
Long: strings.TrimSpace(`
Search for transactions that match exactly the given tags. For example:
$ gaiacli query txs --tags <tag1>:<value1>&<tag2>:<value2>
$ gaiacli query txs --tags '<tag1>:<value1>&<tag2>:<value2>'
`),
RunE: func(cmd *cobra.Command, args []string) error {
tagsStr := viper.GetString(flagTags)
Expand All @@ -48,7 +48,10 @@ $ gaiacli query txs --tags <tag1>:<value1>&<tag2>:<value2>
for _, tag := range tags {
if !strings.Contains(tag, ":") {
return fmt.Errorf("%s should be of the format <key>:<value>", tagsStr)
} else if strings.Count(tag, ":") > 1 {
return fmt.Errorf("%s should only contain one <key>:<value> pair", tagsStr)
}

keyValue := strings.Split(tag, ":")
tag = fmt.Sprintf("%s='%s'", keyValue[0], keyValue[1])
tmTags = append(tmTags, tag)
Expand Down
12 changes: 11 additions & 1 deletion docs/gaia/gaiacli.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,18 @@ gaiacli tx broadcast --node=<node> signedSendTx.json

You can use the transaction search command to query for transactions that match a specific set of `tags`, which are added on every transaction.

Each tag is conformed by a key-value pair in the form of `<tag>:<value>`. Tags can also be combined to query for a more specific result using the `&` symbol.

The command for querying transactions using a `tag` is the following:

```bash
gaiacli query txs --tags='<tag>:<value>'
```

And for using multiple `tags`:

```bash
gaiacli query txs --tags=<tag1>:<value1>&<tag2>:<value2>
gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'
```

::: tip Note
Expand Down

0 comments on commit 7cf5da2

Please sign in to comment.