示例#1
0
文件: client.go 项目: marleyg/tmsp
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
}
示例#2
0
文件: tmsp-cli.go 项目: marleyg/tmsp
// 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))
}
示例#3
0
文件: client.go 项目: marleyg/tmsp
func (cli *TMSPClient) QueryAsync(query []byte) *ReqRes {
	return cli.queueRequest(types.RequestQuery(query))
}