mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 01:41:31 +00:00
cmd: query params are flags
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
abcicli "github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
@ -127,6 +126,22 @@ func main() {
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return cmdQuery(c)
|
return cmdQuery(c)
|
||||||
},
|
},
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "path",
|
||||||
|
Value: "/store",
|
||||||
|
Usage: "Path to prefix the query with",
|
||||||
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "height",
|
||||||
|
Value: 0,
|
||||||
|
Usage: "Height to query the blockchain at",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "prove",
|
||||||
|
Usage: "Whether or not to return a merkle proof of the query result",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Before = before
|
app.Before = before
|
||||||
@ -305,12 +320,11 @@ func cmdCommit(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query application state
|
// Query application state
|
||||||
// TODO: Make request and response support all fields.
|
|
||||||
func cmdQuery(c *cli.Context) error {
|
func cmdQuery(c *cli.Context) error {
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) != 1 {
|
||||||
return errors.New("Command query takes 1 or more arguments")
|
return errors.New("Command query takes 1 argument, the query bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
queryBytes, err := stringOrHexToBytes(args[0])
|
queryBytes, err := stringOrHexToBytes(args[0])
|
||||||
@ -318,25 +332,14 @@ func cmdQuery(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = "/store"
|
path := c.String("path")
|
||||||
if len(args) > 1 {
|
height := c.Int("height")
|
||||||
path = args[1]
|
prove := c.Bool("prove")
|
||||||
}
|
|
||||||
|
|
||||||
var height uint64
|
|
||||||
if len(args) > 2 {
|
|
||||||
height, _ = strconv.ParseUint(args[2], 10, 64)
|
|
||||||
}
|
|
||||||
|
|
||||||
var prove = true
|
|
||||||
if len(args) > 3 {
|
|
||||||
prove, _ = strconv.ParseBool(args[3])
|
|
||||||
}
|
|
||||||
|
|
||||||
resQuery, err := client.QuerySync(types.RequestQuery{
|
resQuery, err := client.QuerySync(types.RequestQuery{
|
||||||
Data: queryBytes,
|
Data: queryBytes,
|
||||||
Path: path,
|
Path: path,
|
||||||
Height: height,
|
Height: uint64(height),
|
||||||
Prove: prove,
|
Prove: prove,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user