Skip to content

Commit

Permalink
[FAB-14324] remove argument from channel.GetMSPIDs
Browse files Browse the repository at this point in the history
- Peer gets channel based on name and then delegates to channel object
- make necessary adjustments to validator ChannelResource and support

Change-Id: I6d0651f1b38ce4d07676df060a5a261fa91b0799
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed Jun 4, 2019
1 parent b4816a6 commit f760891
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/committer/txvalidator/v14/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type ChannelResources interface {

// GetMSPIDs returns the IDs for the application MSPs
// that have been defined in the channel
GetMSPIDs(cid string) []string
GetMSPIDs() []string

// Capabilities defines the capabilities for the application portion of this channel
Capabilities() channelconfig.ApplicationCapabilities
Expand Down
2 changes: 1 addition & 1 deletion core/committer/txvalidator/v14/vscc_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (v *VsccValidatorImpl) GetInfoForValidate(chdr *common.ChannelHeader, ccID
// when we are validating a system CC, we use the default
// VSCC and a default policy that requires one signature
// from any of the members of the channel
p := cauthdsl.SignedByAnyMember(v.cr.GetMSPIDs(chdr.ChannelId))
p := cauthdsl.SignedByAnyMember(v.cr.GetMSPIDs())
policy, err = protoutil.Marshal(p)
if err != nil {
return nil, nil, nil, err
Expand Down
10 changes: 5 additions & 5 deletions core/committer/txvalidator/v20/mocks/channel_resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
type ChannelResources interface {
// GetMSPIDs returns the IDs for the application MSPs
// that have been defined in the channel
GetMSPIDs(cid string) []string
GetMSPIDs() []string
}

// LedgerResources provides access to ledger artefacts or
Expand Down
2 changes: 1 addition & 1 deletion core/committer/txvalidator/v20/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type ChannelResources interface {

// GetMSPIDs returns the IDs for the application MSPs
// that have been defined in the channel
GetMSPIDs(cid string) []string
GetMSPIDs() []string

// Capabilities defines the capabilities for the application portion of this channel
Capabilities() channelconfig.ApplicationCapabilities
Expand Down
2 changes: 1 addition & 1 deletion core/mocks/txvalidator/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (ms *Support) PolicyManager() policies.Manager {
return &mockpolicies.Manager{}
}

func (ms *Support) GetMSPIDs(cid string) []string {
func (ms *Support) GetMSPIDs() []string {
return []string{"SampleOrg"}
}

Expand Down
38 changes: 17 additions & 21 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,18 @@ func (c *chain) Capabilities() channelconfig.ApplicationCapabilities {
return c.cs.Capabilities()
}

func (c *chain) GetMSPIDs(cid string) []string {
return GetMSPIDs(cid)
func (c *chain) GetMSPIDs() []string {
ac, ok := c.cs.ApplicationConfig()
if !ok || ac.Organizations() == nil {
return nil
}

var mspIDs []string
for _, org := range ac.Organizations() {
mspIDs = append(mspIDs, org.MSPID())
}

return mspIDs
}

func (c *chain) MSPManager() msp.MSPManager {
Expand Down Expand Up @@ -712,26 +722,12 @@ func (p *Peer) GetMSPIDs(cid string) []string {
chains.RLock()
defer chains.RUnlock()

if c, ok := chains.list[cid]; ok {
if c == nil || c.cs == nil {
return nil
}
ac, ok := c.cs.ApplicationConfig()
if !ok || ac.Organizations() == nil {
return nil
}

orgs := ac.Organizations()
toret := make([]string, len(orgs))
i := 0
for _, org := range orgs {
toret[i] = org.MSPID()
i++
}

return toret
c, ok := chains.list[cid]
if !ok {
return nil
}
return nil

return c.GetMSPIDs()
}

// GetPolicyManager returns the policy manager of the chain with chain ID. Note that this
Expand Down

0 comments on commit f760891

Please sign in to comment.