本文整理汇总了Golang中github.com/openblockchain/obc-peer/openchain/crypto.Client.GetTCertificateHandlerNext方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.GetTCertificateHandlerNext方法的具体用法?Golang Client.GetTCertificateHandlerNext怎么用?Golang Client.GetTCertificateHandlerNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openblockchain/obc-peer/openchain/crypto.Client
的用法示例。
在下文中一共展示了Client.GetTCertificateHandlerNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: transferOwnership
func transferOwnership(owner crypto.Client, ownerCert crypto.CertificateHandler, asset string, newOwnerCert crypto.CertificateHandler) error {
// Get a transaction handler to be used to submit the execute transaction
// and bind the chaincode access control logic using the binding
submittingCertHandler, err := owner.GetTCertificateHandlerNext()
if err != nil {
return err
}
txHandler, err := submittingCertHandler.GetTransactionHandler()
if err != nil {
return err
}
binding, err := txHandler.GetBinding()
if err != nil {
return err
}
chaincodeInput := &pb.ChaincodeInput{Function: "transfer", Args: []string{asset, string(newOwnerCert.GetCertificate())}}
chaincodeInputRaw, err := proto.Marshal(chaincodeInput)
if err != nil {
return err
}
// Access control. Owner signs chaincodeInputRaw || binding to confirm his identity
sigma, err := ownerCert.Sign(append(chaincodeInputRaw, binding...))
if err != nil {
return err
}
// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: "mycc"},
CtorMsg: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: pb.ConfidentialityLevel_PUBLIC,
}
var ctx = context.Background()
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
tid := chaincodeInvocationSpec.ChaincodeSpec.ChaincodeID.Name
// Now create the Transactions message and send to Peer.
transaction, err := txHandler.NewChaincodeExecute(chaincodeInvocationSpec, tid)
if err != nil {
return fmt.Errorf("Error deploying chaincode: %s ", err)
}
ledger, err := ledger.GetLedger()
ledger.BeginTxBatch("1")
_, err = chaincode.Execute(ctx, chaincode.GetChain(chaincode.DefaultChain), transaction)
if err != nil {
return fmt.Errorf("Error deploying chaincode: %s", err)
}
ledger.CommitTxBatch("1", []*pb.Transaction{transaction}, nil, nil)
return err
}