本文整理匯總了Golang中github.com/hyperledger/fabric/core/crypto.Client.NewChaincodeQuery方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.NewChaincodeQuery方法的具體用法?Golang Client.NewChaincodeQuery怎麽用?Golang Client.NewChaincodeQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/crypto.Client
的用法示例。
在下文中一共展示了Client.NewChaincodeQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createTransaction
func createTransaction(invokeTx bool, spec *pb.ChaincodeInvocationSpec, uuid string) (*pb.Transaction, error) {
var tx *pb.Transaction
var err error
var sec crypto.Client
if nil != sec {
sec, err = crypto.InitClient(spec.ChaincodeSpec.SecureContext, nil)
defer crypto.CloseClient(sec)
if nil != err {
return nil, err
}
if invokeTx {
tx, err = sec.NewChaincodeExecute(spec, uuid)
} else {
tx, err = sec.NewChaincodeQuery(spec, uuid)
}
if nil != err {
return nil, err
}
} else {
var t pb.Transaction_Type
if invokeTx {
t = pb.Transaction_CHAINCODE_INVOKE
} else {
t = pb.Transaction_CHAINCODE_QUERY
}
tx, err = pb.NewChaincodeExecute(spec, uuid, t)
if nil != err {
return nil, err
}
}
return tx, nil
}
示例2: createExecTx
func (d *Devops) createExecTx(spec *pb.ChaincodeInvocationSpec, attributes []string, uuid string, invokeTx bool, sec crypto.Client) (*pb.Transaction, error) {
var tx *pb.Transaction
var err error
//TODO What should we do with the attributes
if nil != sec {
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Creating secure invocation transaction %s", uuid)
}
if invokeTx {
tx, err = sec.NewChaincodeExecute(spec, uuid, attributes...)
} else {
tx, err = sec.NewChaincodeQuery(spec, uuid, attributes...)
}
if nil != err {
return nil, err
}
} else {
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Creating invocation transaction (%s)", uuid)
}
var t pb.Transaction_Type
if invokeTx {
t = pb.Transaction_CHAINCODE_INVOKE
} else {
t = pb.Transaction_CHAINCODE_QUERY
}
tx, err = pb.NewChaincodeExecute(spec, uuid, t)
if nil != err {
return nil, err
}
}
return tx, nil
}
示例3: whoIsTheOwner
func whoIsTheOwner(invoker crypto.Client, asset string) (transaction *pb.Transaction, resp *pb.Response, err error) {
chaincodeInput := &pb.ChaincodeInput{Args: util.ToChaincodeArgs("query", asset)}
// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
ConfidentialityLevel: confidentialityLevel,
}
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
// Now create the Transactions message and send to Peer.
transaction, err = invoker.NewChaincodeQuery(chaincodeInvocationSpec, util.GenerateUUID())
if err != nil {
return nil, nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
resp, err = processTransaction(transaction)
return
}