代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package ccprovider
import (
"bytes"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/common/sysccprovider"
)
// IsChaincodeDeployed returns true if the chaincode with given name and version is deployed
func IsChaincodeDeployed(chainid, ccName, ccVersion string, ccHash []byte, sccp sysccprovider.SystemChaincodeProvider) (bool, error) {
qe, err := sccp.GetQueryExecutorForLedger(chainid)
if err != nil {
return false, fmt.Errorf("Could not retrieve QueryExecutor for channel %s, error %s", chainid, err)
}
defer qe.Done()
// XXX We are leaking details of the LSCC table structure to other parts of the code, and this is terrible
chaincodeDataBytes, err := qe.GetState("lscc", ccName)
if err != nil {
return false, fmt.Errorf("Could not retrieve state for chaincode %s on channel %s, error %s", ccName, chainid, err)
}
if chaincodeDataBytes == nil {
return false, nil
}
chaincodeData := &ChaincodeData{}
err = proto.Unmarshal(chaincodeDataBytes, chaincodeData)
if err != nil {
return false, fmt.Errorf("Unmarshalling ChaincodeQueryResponse failed, error %s", err)
}
return chaincodeData.CCVersion() == ccVersion && bytes.Equal(chaincodeData.Hash(), ccHash), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。