本文整理匯總了Golang中github.com/hyperledger/fabric/core/crypto.Client.NewChaincodeDeployTransaction方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.NewChaincodeDeployTransaction方法的具體用法?Golang Client.NewChaincodeDeployTransaction怎麽用?Golang Client.NewChaincodeDeployTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/crypto.Client
的用法示例。
在下文中一共展示了Client.NewChaincodeDeployTransaction方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deployInternal
func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler) (resp *pb.Response, err error) {
// Prepare the spec. The metadata includes the identity of the administrator
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Path: "github.com/hyperledger/fabric/examples/chaincode/go/asset_management"},
//ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
Metadata: adminCert.GetCertificate(),
ConfidentialityLevel: confidentialityLevel,
}
// First build the deployment spec
cds, err := getChaincodeBytes(spec)
if err != nil {
return nil, fmt.Errorf("Error getting deployment spec: %s ", err)
}
// Now create the Transactions message and send to Peer.
transaction, err := deployer.NewChaincodeDeployTransaction(cds, cds.ChaincodeSpec.ChaincodeID.Name)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
resp, err = processTransaction(transaction)
appLogger.Debugf("resp [%s]", resp.String())
chaincodeName = cds.ChaincodeSpec.ChaincodeID.Name
appLogger.Debugf("ChaincodeName [%s]", chaincodeName)
return
}
示例2: Deploy
// Deploy deploys the supplied chaincode image to the validators through a transaction
func (d *Devops) Deploy(ctx context.Context, spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error) {
// get the deployment spec
chaincodeDeploymentSpec, err := d.getChaincodeBytes(ctx, spec)
if err != nil {
devopsLogger.Error(fmt.Sprintf("Error deploying chaincode spec: %v\n\n error: %s", spec, err))
return nil, err
}
// Now create the Transactions message and send to Peer.
transID := chaincodeDeploymentSpec.ChaincodeSpec.ChaincodeID.Name
var tx *pb.Transaction
var sec crypto.Client
if peer.SecurityEnabled() {
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Initializing secure devops using context %s", spec.SecureContext)
}
sec, err = crypto.InitClient(spec.SecureContext, nil)
defer crypto.CloseClient(sec)
// remove the security context since we are no longer need it down stream
spec.SecureContext = ""
if nil != err {
return nil, err
}
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Creating secure transaction %s", transID)
}
tx, err = sec.NewChaincodeDeployTransaction(chaincodeDeploymentSpec, transID, spec.Attributes...)
if nil != err {
return nil, err
}
} else {
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Creating deployment transaction (%s)", transID)
}
tx, err = pb.NewChaincodeDeployTransaction(chaincodeDeploymentSpec, transID)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
}
if devopsLogger.IsEnabledFor(logging.DEBUG) {
devopsLogger.Debugf("Sending deploy transaction (%s) to validator", tx.Uuid)
}
resp := d.coord.ExecuteTransaction(tx)
if resp.Status == pb.Response_FAILURE {
err = fmt.Errorf(string(resp.Msg))
}
return chaincodeDeploymentSpec, err
}
示例3: createDeployTransaction
func createDeployTransaction(dspec *pb.ChaincodeDeploymentSpec, uuid string) (*pb.Transaction, error) {
var tx *pb.Transaction
var err error
var sec crypto.Client
if dspec.ChaincodeSpec.SecureContext != "" {
sec, err = crypto.InitClient(dspec.ChaincodeSpec.SecureContext, nil)
defer crypto.CloseClient(sec)
if nil != err {
return nil, err
}
tx, err = sec.NewChaincodeDeployTransaction(dspec, uuid)
if nil != err {
return nil, err
}
} else {
tx, err = pb.NewChaincodeDeployTransaction(dspec, uuid)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
}
return tx, nil
}