63 Star 183 Fork 3

Gitee 极速下载/hyperledger-fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
support.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
Will Lahti 提交于 2018-10-29 12:07 . Replace / in logger names with dots
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/chaincode"
"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/common/policies/inquire"
common2 "github.com/hyperledger/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)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/hyperledger-fabric.git
git@gitee.com:mirrors/hyperledger-fabric.git
mirrors
hyperledger-fabric
hyperledger-fabric
v1.4.6

搜索帮助