Skip to content

Commit bc6ce70

Browse files
committed
[FAB-6228] add implementation of ChaincodeByName
This change set introduces the proper implementation for the ChaincodeByName function exposed by the Support interface for the endorser. Change-Id: If70b5e8171a4cffcbbd941220994f477fe5e4b0c Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
1 parent f47dd7f commit bc6ce70

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

core/peer/peer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,17 @@ func GetLedger(cid string) ledger.PeerLedger {
450450
return nil
451451
}
452452

453+
// GetResourcesConfig returns the resources configuration of the chain with channel ID. Note that this
454+
// call returns nil if chain cid has not been created.
455+
func GetResourcesConfig(cid string) resourcesconfig.Resources {
456+
chains.RLock()
457+
defer chains.RUnlock()
458+
if c, ok := chains.list[cid]; ok {
459+
return c.cs.bundleSource.StableBundle()
460+
}
461+
return nil
462+
}
463+
453464
// GetChannelConfig returns the channel configuration of the chain with channel ID. Note that this
454465
// call returns nil if chain cid has not been created.
455466
func GetChannelConfig(cid string) channelconfig.Resources {

core/peer/support.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ func (s *supportImpl) GetApplicationConfig(cid string) (channelconfig.Applicatio
4343
}
4444

4545
func (s *supportImpl) ChaincodeByName(chainname, ccname string) (resourcesconfig.ChaincodeDefinition, bool) {
46-
// FIXME: implement me properly
47-
return nil, false
46+
rc := GetResourcesConfig(chainname)
47+
if rc == nil {
48+
return nil, false
49+
}
50+
51+
return rc.ChaincodeRegistry().ChaincodeByName(ccname)
4852
}
4953

5054
type SupportFactoryImpl struct {

0 commit comments

Comments
 (0)