63 Star 181 Fork 3

Gitee 极速下载 / hyperledger-fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
support.go 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package peer
import (
"github.com/hyperledger/fabric/common/channelconfig"
"github.com/hyperledger/fabric/common/resourcesconfig"
)
var supportFactory SupportFactory
// SupportFactory is a factory of Support interfaces
type SupportFactory interface {
// NewSupport returns a Support interface
NewSupport() Support
}
// Support gives access to peer resources and avoids calls to static methods
type Support interface {
// GetApplicationConfig returns the configtxapplication.SharedConfig for the channel
// and whether the Application config exists
GetApplicationConfig(cid string) (channelconfig.Application, bool)
// ChaincodeByName returns the definition (and whether they exist)
// for a chaincode in a specific channel
ChaincodeByName(chainname, ccname string) (resourcesconfig.ChaincodeDefinition, bool)
}
type supportImpl struct {
}
func (s *supportImpl) GetApplicationConfig(cid string) (channelconfig.Application, bool) {
cc := GetChannelConfig(cid)
if cc == nil {
return nil, false
}
return cc.ApplicationConfig()
}
func (s *supportImpl) ChaincodeByName(chainname, ccname string) (resourcesconfig.ChaincodeDefinition, bool) {
rc := GetResourcesConfig(chainname)
if rc == nil {
return nil, false
}
return rc.ChaincodeRegistry().ChaincodeByName(ccname)
}
type SupportFactoryImpl struct {
}
func (c *SupportFactoryImpl) NewSupport() Support {
return &supportImpl{}
}
// RegisterSupportFactory should be called to specify
// which factory should be used to serve GetSupport calls
func RegisterSupportFactory(ccfact SupportFactory) {
supportFactory = ccfact
}
// GetSupport returns a new Support instance by calling the factory
func GetSupport() Support {
if supportFactory == nil {
panic("The factory must be set first via RegisterSupportFactory")
}
return supportFactory.NewSupport()
}
// init is called when this package is loaded; this way by default,
// all calls to GetSupport will be satisfied by SupportFactoryImpl,
// unless RegisterSupportFactory is called again
func init() {
RegisterSupportFactory(&SupportFactoryImpl{})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/hyperledger-fabric.git
git@gitee.com:mirrors/hyperledger-fabric.git
mirrors
hyperledger-fabric
hyperledger-fabric
v1.1.0-rc1

搜索帮助

344bd9b3 5694891 D2dac590 5694891