Skip to content

Commit f664fdf

Browse files
author
Jason Yellick
committed
[FAB-4465] Expose orderer orgs via config
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 <[email protected]>
1 parent 6b75101 commit f664fdf

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

common/config/api.go

+3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ type Orderer interface {
9393
// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers
9494
// used for ordering
9595
KafkaBrokers() []string
96+
97+
// Organizations returns the organizations for the ordering service
98+
Organizations() map[string]Org
9699
}
97100

98101
type ValueProposer interface {

common/config/orderer.go

+15
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type OrdererConfig struct {
8989
*standardValues
9090
protos *OrdererProtos
9191
ordererGroup *OrdererGroup
92+
orgs map[string]Org
9293

9394
batchTimeout time.Duration
9495
}
@@ -140,6 +141,11 @@ func (oc *OrdererConfig) MaxChannelsCount() uint64 {
140141
return oc.protos.ChannelRestrictions.MaxCount
141142
}
142143

144+
// Organizations returns a map of the orgs in the channel
145+
func (oc *OrdererConfig) Organizations() map[string]Org {
146+
return oc.orgs
147+
}
148+
143149
func (oc *OrdererConfig) Validate(tx interface{}, groups map[string]ValueProposer) error {
144150
for _, validator := range []func() error{
145151
oc.validateConsensusType,
@@ -152,6 +158,15 @@ func (oc *OrdererConfig) Validate(tx interface{}, groups map[string]ValuePropose
152158
}
153159
}
154160

161+
var ok bool
162+
oc.orgs = make(map[string]Org)
163+
for key, value := range groups {
164+
oc.orgs[key], ok = value.(*OrganizationGroup)
165+
if !ok {
166+
return fmt.Errorf("Organization sub-group %s was not an OrgGroup, actually %T", key, value)
167+
}
168+
}
169+
155170
return nil
156171
}
157172

common/mocks/config/orderer.go

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package config
1919
import (
2020
"time"
2121

22+
"github.com/hyperledger/fabric/common/config"
2223
ab "github.com/hyperledger/fabric/protos/orderer"
2324
)
2425

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

3942
// ConsensusType returns the ConsensusTypeVal
@@ -60,3 +63,8 @@ func (scm *Orderer) KafkaBrokers() []string {
6063
func (scm *Orderer) MaxChannelsCount() uint64 {
6164
return scm.MaxChannelsCountVal
6265
}
66+
67+
// Organizations returns OrganizationsVal
68+
func (scm *Orderer) Organizations() map[string]config.Org {
69+
return scm.OrganizationsVal
70+
}

0 commit comments

Comments
 (0)