Exemple #1
0
func (cli *TMSPClient) QuerySync(query []byte) (code types.CodeType, result []byte, log string, err error) {
	reqres := cli.queueRequest(types.RequestQuery(query))
	cli.FlushSync()
	if cli.err != nil {
		return types.CodeType_InternalError, nil, "", cli.err
	}
	res := reqres.Response
	return res.Code, res.Data, res.Log, nil
}
Exemple #2
0
// Query application state
func cmdQuery(c *cli.Context) {
	args := c.Args()
	if len(args) != 1 {
		fmt.Println("query takes 1 argument")
		return
	}
	queryString := args[0]
	query := []byte(queryString)
	if len(queryString) > 2 && strings.HasPrefix(queryString, "0x") {
		var err error
		query, err = hex.DecodeString(queryString[2:])
		if err != nil {
			fmt.Println(err.Error())
			return
		}
	}

	res, err := makeRequest(conn, types.RequestQuery(query))
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	printResponse(res, string(res.Data))
}
Exemple #3
0
func (cli *TMSPClient) QueryAsync(query []byte) *ReqRes {
	return cli.queueRequest(types.RequestQuery(query))
}