1 Star 1 Fork 0

Hyperledger Fabric 国密/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
support.go 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
Jtyoui 提交于 2021-07-22 15:59 +08:00 . 国密
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import (
"github.com/golang/protobuf/proto"
"gitee.com/hyperledger-fabric-gm/fabric/common/chaincode"
"gitee.com/hyperledger-fabric-gm/fabric/common/flogging"
"gitee.com/hyperledger-fabric-gm/fabric/common/policies"
"gitee.com/hyperledger-fabric-gm/fabric/common/policies/inquire"
common2 "gitee.com/hyperledger-fabric-gm/fabric/protos/common"
)
var logger = flogging.MustGetLogger("discovery.DiscoverySupport")
type MetadataRetriever interface {
Metadata(channel string, cc string, loadCollections bool) *chaincode.Metadata
}
// DiscoverySupport implements support that is used for service discovery
// that is related to chaincode
type DiscoverySupport struct {
ci MetadataRetriever
}
// NewDiscoverySupport creates a new DiscoverySupport
func NewDiscoverySupport(ci MetadataRetriever) *DiscoverySupport {
s := &DiscoverySupport{
ci: ci,
}
return s
}
func (s *DiscoverySupport) PolicyByChaincode(channel string, cc string) policies.InquireablePolicy {
chaincodeData := s.ci.Metadata(channel, cc, false)
if chaincodeData == nil {
logger.Info("Chaincode", cc, "wasn't found")
return nil
}
pol := &common2.SignaturePolicyEnvelope{}
if err := proto.Unmarshal(chaincodeData.Policy, pol); err != nil {
logger.Warning("Failed unmarshaling policy for chaincode", cc, ":", err)
return nil
}
if len(pol.Identities) == 0 || pol.Rule == nil {
logger.Warningf("Invalid policy, either Identities(%v) or Rule(%v) are empty:", pol.Identities, pol.Rule)
return nil
}
return inquire.NewInquireableSignaturePolicy(pol)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/hyperledger-fabric-gm/fabric.git
git@gitee.com:hyperledger-fabric-gm/fabric.git
hyperledger-fabric-gm
fabric
fabric
v1.4.9

搜索帮助