Skip to content

Commit

Permalink
[FAB-6228] add implementation of ChaincodeByName
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ale-linux committed Dec 8, 2017
1 parent f47dd7f commit bc6ce70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@ func GetLedger(cid string) ledger.PeerLedger {
return nil
}

// GetResourcesConfig returns the resources configuration of the chain with channel ID. Note that this
// call returns nil if chain cid has not been created.
func GetResourcesConfig(cid string) resourcesconfig.Resources {
chains.RLock()
defer chains.RUnlock()
if c, ok := chains.list[cid]; ok {
return c.cs.bundleSource.StableBundle()
}
return nil
}

// GetChannelConfig returns the channel configuration of the chain with channel ID. Note that this
// call returns nil if chain cid has not been created.
func GetChannelConfig(cid string) channelconfig.Resources {
Expand Down
8 changes: 6 additions & 2 deletions core/peer/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ func (s *supportImpl) GetApplicationConfig(cid string) (channelconfig.Applicatio
}

func (s *supportImpl) ChaincodeByName(chainname, ccname string) (resourcesconfig.ChaincodeDefinition, bool) {
// FIXME: implement me properly
return nil, false
rc := GetResourcesConfig(chainname)
if rc == nil {
return nil, false
}

return rc.ChaincodeRegistry().ChaincodeByName(ccname)
}

type SupportFactoryImpl struct {
Expand Down

0 comments on commit bc6ce70

Please sign in to comment.