代码拉取完成,页面将自动刷新
/*
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{})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。