github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/common/config/consortiums_util.go (about) 1 /* 2 Copyright IBM Corp. 2017 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package config 18 19 import ( 20 cb "github.com/inklabsfoundation/inkchain/protos/common" 21 "github.com/inklabsfoundation/inkchain/protos/utils" 22 ) 23 24 const ( 25 // ChannelCreationPolicyKey is the key for the ChannelCreationPolicy value 26 ChannelCreationPolicyKey = "ChannelCreationPolicy" 27 ) 28 29 // TemplateConsortiumsGroup creates an empty consortiums group 30 func TemplateConsortiumsGroup() *cb.ConfigGroup { 31 result := cb.NewConfigGroup() 32 result.Groups[ConsortiumsGroupKey] = cb.NewConfigGroup() 33 return result 34 } 35 36 // TemplateConsortiumChannelCreationPolicy sets the ChannelCreationPolicy for a given consortium 37 func TemplateConsortiumChannelCreationPolicy(name string, policy *cb.Policy) *cb.ConfigGroup { 38 result := TemplateConsortiumsGroup() 39 result.Groups[ConsortiumsGroupKey].Groups[name] = cb.NewConfigGroup() 40 result.Groups[ConsortiumsGroupKey].Groups[name].Values[ChannelCreationPolicyKey] = &cb.ConfigValue{ 41 Value: utils.MarshalOrPanic(policy), 42 } 43 return result 44 }