代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package lifecycle
import (
"github.com/hyperledger/fabric/core/chaincode/persistence"
"github.com/pkg/errors"
)
// ChaincodeStore provides a way to persist chaincodes
type ChaincodeStore interface {
Save(name, version string, ccInstallPkg []byte) (hash []byte, err error)
}
type PackageParser interface {
Parse(data []byte) (*persistence.ChaincodePackage, error)
}
// Lifecycle implements the lifecycle operations which are invoked
// by the SCC as well as internally
type Lifecycle struct {
ChaincodeStore ChaincodeStore
PackageParser PackageParser
}
// InstallChaincode installs a given chaincode to the peer's chaincode store.
// It returns the hash to reference the chaincode by or an error on failure.
func (l *Lifecycle) InstallChaincode(name, version string, chaincodeInstallPackage []byte) ([]byte, error) {
// Let's validate that the chaincodeInstallPackage is at least well formed before writing it
_, err := l.PackageParser.Parse(chaincodeInstallPackage)
if err != nil {
return nil, errors.WithMessage(err, "could not parse as a chaincode install package")
}
hash, err := l.ChaincodeStore.Save(name, version, chaincodeInstallPackage)
if err != nil {
return nil, errors.WithMessage(err, "could not save cc install package")
}
return hash, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。