Skip to content

Commit c3c64fa

Browse files
Jason Yellickkchristidis
Jason Yellick
authored andcommitted
[FAB-2702] (PA) Specify consortium in chan config
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 <[email protected]> Signed-off-by: Kostas Christidis <[email protected]>
1 parent 7998d07 commit c3c64fa

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

common/config/channel.go

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import (
2828

2929
// Channel config keys
3030
const (
31+
// ConsortiumKey is the key for the cb.ConfigValue for the Consortium message
32+
ConsortiumKey = "Consortium"
33+
3134
// HashingAlgorithmKey is the cb.ConfigItem type key name for the HashingAlgorithm message
3235
HashingAlgorithmKey = "HashingAlgorithm"
3336

@@ -60,6 +63,7 @@ type ChannelProtos struct {
6063
HashingAlgorithm *cb.HashingAlgorithm
6164
BlockDataHashingStructure *cb.BlockDataHashingStructure
6265
OrdererAddresses *cb.OrdererAddresses
66+
Consortium *cb.Consortium
6367
}
6468

6569
type channelConfigSetter struct {
@@ -165,6 +169,11 @@ func (cc *ChannelConfig) OrdererAddresses() []string {
165169
return cc.protos.OrdererAddresses.Addresses
166170
}
167171

172+
// ConsortiumName returns the name of the consortium this channel was created under
173+
func (cc *ChannelConfig) ConsortiumName() string {
174+
return cc.protos.Consortium.Name
175+
}
176+
168177
// Validate inspects the generated configuration protos, ensures that the values are correct, and
169178
// sets the ChannelConfig fields that may be referenced after Commit
170179
func (cc *ChannelConfig) Validate(tx interface{}, groups map[string]ValueProposer) error {

common/config/channel_util.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ func configGroup(key string, value []byte) *cb.ConfigGroup {
3434
return result
3535
}
3636

37+
// TemplateConsortiumName creates a ConfigGroup representing the ConsortiumName
38+
func TemplateConsortium(name string) *cb.ConfigGroup {
39+
return configGroup(ConsortiumKey, utils.MarshalOrPanic(&cb.Consortium{Name: name}))
40+
}
41+
3742
// TemplateHashingAlgorithm creates a ConfigGroup representing the HashingAlgorithm
3843
func TemplateHashingAlgorithm(name string) *cb.ConfigGroup {
3944
return configGroup(HashingAlgorithmKey, utils.MarshalOrPanic(&cb.HashingAlgorithm{Name: name}))
40-
4145
}
4246

4347
// DefaultHashingAlgorithm creates a headerless config item for the default hashing algorithm

protos/common/common.pb.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configuration.pb.go

+27-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configuration.proto

+5
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ message BlockDataHashingStructure {
4141
message OrdererAddresses {
4242
repeated string addresses = 1;
4343
}
44+
45+
// Consortium represents the consortium context in which the channel was created
46+
message Consortium {
47+
string name = 1;
48+
}

0 commit comments

Comments
 (0)