Skip to content

Commit

Permalink
[FAB-4465] Expose orderer orgs via config
Browse files Browse the repository at this point in the history
Although the config carries information about the orderer orgs, there is
currently no interface to access them, like there is for the application
orgs.

This CR simply adds an accessor method for the orderer orgs.

Change-Id: I32b726997edf5d0183805c0b0c768f98a8f80c63
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Jun 8, 2017
1 parent 6b75101 commit f664fdf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/config/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type Orderer interface {
// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers
// used for ordering
KafkaBrokers() []string

// Organizations returns the organizations for the ordering service
Organizations() map[string]Org
}

type ValueProposer interface {
Expand Down
15 changes: 15 additions & 0 deletions common/config/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type OrdererConfig struct {
*standardValues
protos *OrdererProtos
ordererGroup *OrdererGroup
orgs map[string]Org

batchTimeout time.Duration
}
Expand Down Expand Up @@ -140,6 +141,11 @@ func (oc *OrdererConfig) MaxChannelsCount() uint64 {
return oc.protos.ChannelRestrictions.MaxCount
}

// Organizations returns a map of the orgs in the channel
func (oc *OrdererConfig) Organizations() map[string]Org {
return oc.orgs
}

func (oc *OrdererConfig) Validate(tx interface{}, groups map[string]ValueProposer) error {
for _, validator := range []func() error{
oc.validateConsensusType,
Expand All @@ -152,6 +158,15 @@ func (oc *OrdererConfig) Validate(tx interface{}, groups map[string]ValuePropose
}
}

var ok bool
oc.orgs = make(map[string]Org)
for key, value := range groups {
oc.orgs[key], ok = value.(*OrganizationGroup)
if !ok {
return fmt.Errorf("Organization sub-group %s was not an OrgGroup, actually %T", key, value)
}
}

return nil
}

Expand Down
8 changes: 8 additions & 0 deletions common/mocks/config/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package config
import (
"time"

"github.com/hyperledger/fabric/common/config"
ab "github.com/hyperledger/fabric/protos/orderer"
)

Expand All @@ -34,6 +35,8 @@ type Orderer struct {
KafkaBrokersVal []string
// MaxChannelsCountVal is returns as the result of MaxChannelsCount()
MaxChannelsCountVal uint64
// OrganizationsVal is returned as the result of Organizations()
OrganizationsVal map[string]config.Org
}

// ConsensusType returns the ConsensusTypeVal
Expand All @@ -60,3 +63,8 @@ func (scm *Orderer) KafkaBrokers() []string {
func (scm *Orderer) MaxChannelsCount() uint64 {
return scm.MaxChannelsCountVal
}

// Organizations returns OrganizationsVal
func (scm *Orderer) Organizations() map[string]config.Org {
return scm.OrganizationsVal
}

0 comments on commit f664fdf

Please sign in to comment.