Skip to content

Commit

Permalink
[FAB-2702] (PA) Specify consortium in chan config
Browse files Browse the repository at this point in the history
In order to associate channels to the consortium they were created in
the context of, it's necessary to add a proto definition which defines
the consortium name a channel was created for.

This CR defines the protos and updates the config structures to
appropriately parse the consortium name.

Change-Id: Ie10c3273c1801201ff99f7eed417dddfac778315
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
Jason Yellick authored and kchristidis committed Apr 26, 2017
1 parent 7998d07 commit c3c64fa
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
9 changes: 9 additions & 0 deletions common/config/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (

// Channel config keys
const (
// ConsortiumKey is the key for the cb.ConfigValue for the Consortium message
ConsortiumKey = "Consortium"

// HashingAlgorithmKey is the cb.ConfigItem type key name for the HashingAlgorithm message
HashingAlgorithmKey = "HashingAlgorithm"

Expand Down Expand Up @@ -60,6 +63,7 @@ type ChannelProtos struct {
HashingAlgorithm *cb.HashingAlgorithm
BlockDataHashingStructure *cb.BlockDataHashingStructure
OrdererAddresses *cb.OrdererAddresses
Consortium *cb.Consortium
}

type channelConfigSetter struct {
Expand Down Expand Up @@ -165,6 +169,11 @@ func (cc *ChannelConfig) OrdererAddresses() []string {
return cc.protos.OrdererAddresses.Addresses
}

// ConsortiumName returns the name of the consortium this channel was created under
func (cc *ChannelConfig) ConsortiumName() string {
return cc.protos.Consortium.Name
}

// Validate inspects the generated configuration protos, ensures that the values are correct, and
// sets the ChannelConfig fields that may be referenced after Commit
func (cc *ChannelConfig) Validate(tx interface{}, groups map[string]ValueProposer) error {
Expand Down
6 changes: 5 additions & 1 deletion common/config/channel_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ func configGroup(key string, value []byte) *cb.ConfigGroup {
return result
}

// TemplateConsortiumName creates a ConfigGroup representing the ConsortiumName
func TemplateConsortium(name string) *cb.ConfigGroup {
return configGroup(ConsortiumKey, utils.MarshalOrPanic(&cb.Consortium{Name: name}))
}

// TemplateHashingAlgorithm creates a ConfigGroup representing the HashingAlgorithm
func TemplateHashingAlgorithm(name string) *cb.ConfigGroup {
return configGroup(HashingAlgorithmKey, utils.MarshalOrPanic(&cb.HashingAlgorithm{Name: name}))

}

// DefaultHashingAlgorithm creates a headerless config item for the default hashing algorithm
Expand Down
1 change: 1 addition & 0 deletions protos/common/common.pb.go

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

42 changes: 27 additions & 15 deletions protos/common/configuration.pb.go

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

5 changes: 5 additions & 0 deletions protos/common/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ message BlockDataHashingStructure {
message OrdererAddresses {
repeated string addresses = 1;
}

// Consortium represents the consortium context in which the channel was created
message Consortium {
string name = 1;
}

0 comments on commit c3c64fa

Please sign in to comment.