3 Star 6 Fork 7

Gitee 极速下载/Hyperledger fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
query.go 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import (
"errors"
"fmt"
"github.com/spf13/cobra"
)
var chaincodeQueryCmd *cobra.Command
// queryCmd returns the cobra command for Chaincode Query
func queryCmd(cf *ChaincodeCmdFactory) *cobra.Command {
chaincodeQueryCmd = &cobra.Command{
Use: "query",
Short: fmt.Sprintf("Query using the specified %s.", chainFuncName),
Long: fmt.Sprintf("Get endorsed result of %s function call and print it. It won't generate transaction.", chainFuncName),
ValidArgs: []string{"1"},
RunE: func(cmd *cobra.Command, args []string) error {
return chaincodeQuery(cmd, cf)
},
}
flagList := []string{
"ctor",
"name",
"channelID",
"peerAddresses",
"tlsRootCertFiles",
"connectionProfile",
}
attachFlags(chaincodeQueryCmd, flagList)
chaincodeQueryCmd.Flags().BoolVarP(&chaincodeQueryRaw, "raw", "r", false,
"If true, output the query value as raw bytes, otherwise format as a printable string")
chaincodeQueryCmd.Flags().BoolVarP(&chaincodeQueryHex, "hex", "x", false,
"If true, output the query value byte array in hexadecimal. Incompatible with --raw")
return chaincodeQueryCmd
}
func chaincodeQuery(cmd *cobra.Command, cf *ChaincodeCmdFactory) error {
if channelID == "" {
return errors.New("The required parameter 'channelID' is empty. Rerun the command with -C flag")
}
// Parsing of the command line is done so silence cmd usage
cmd.SilenceUsage = true
var err error
if cf == nil {
cf, err = InitCmdFactory(cmd.Name(), true, false)
if err != nil {
return err
}
}
return chaincodeInvokeOrQuery(cmd, false, cf)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/fabric.git
git@gitee.com:mirrors/fabric.git
mirrors
fabric
Hyperledger fabric
v1.4.0-rc2

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385