@@ -19,9 +19,11 @@ package provisional
1919import (
2020 "fmt"
2121
22+ "github.com/hyperledger/fabric/common/cauthdsl"
2223 "github.com/hyperledger/fabric/common/configtx"
2324 "github.com/hyperledger/fabric/common/genesis"
2425 "github.com/hyperledger/fabric/orderer/common/bootstrap"
26+ "github.com/hyperledger/fabric/orderer/common/sharedconfig"
2527 "github.com/hyperledger/fabric/orderer/localconfig"
2628 cb "github.com/hyperledger/fabric/protos/common"
2729 ab "github.com/hyperledger/fabric/protos/orderer"
@@ -36,8 +38,6 @@ type Generator interface {
3638}
3739
3840const (
39- msgVersion = int32 (1 )
40-
4141 // ConsensusTypeSolo identifies the solo consensus implementation.
4242 ConsensusTypeSolo = "solo"
4343 // ConsensusTypeKafka identifies the Kafka-based consensus implementation.
@@ -53,64 +53,61 @@ const (
5353
5454 // AcceptAllPolicyKey is the key of the AcceptAllPolicy.
5555 AcceptAllPolicyKey = "AcceptAllPolicy"
56-
57- // These values are fixed for the genesis block.
58- lastModified = 0
59- epoch = 0
6056)
6157
6258// DefaultChainCreationPolicyNames is the default value of ChainCreatorsKey.
6359var DefaultChainCreationPolicyNames = []string {AcceptAllPolicyKey }
6460
65- type commonBootstrapper struct {
66- chainID string
67- consensusType string
68- batchSize * ab.BatchSize
69- batchTimeout string
70- }
71-
72- type soloBootstrapper struct {
73- commonBootstrapper
74- }
75-
76- type kafkaBootstrapper struct {
77- commonBootstrapper
78- kafkaBrokers []string
61+ type bootstrapper struct {
62+ minimalItems []* cb.ConfigurationItem
63+ systemChainItems []* cb.ConfigurationItem
7964}
8065
8166// New returns a new provisional bootstrap helper.
8267func New (conf * config.TopLevel ) Generator {
83- cbs := & commonBootstrapper {
84- chainID : TestChainID ,
85- consensusType : conf .Genesis .OrdererType ,
86- batchSize : & ab.BatchSize {
87- MaxMessageCount : conf .Genesis .BatchSize .MaxMessageCount ,
88- AbsoluteMaxBytes : conf .Genesis .BatchSize .AbsoluteMaxBytes ,
89- PreferredMaxBytes : conf .Genesis .BatchSize .PreferredMaxBytes ,
68+ bs := & bootstrapper {
69+ minimalItems : []* cb.ConfigurationItem {
70+ // Orderer Config Types
71+ sharedconfig .TemplateConsensusType (conf .Genesis .OrdererType ),
72+ sharedconfig .TemplateBatchSize (& ab.BatchSize {
73+ MaxMessageCount : conf .Genesis .BatchSize .MaxMessageCount ,
74+ AbsoluteMaxBytes : conf .Genesis .BatchSize .AbsoluteMaxBytes ,
75+ PreferredMaxBytes : conf .Genesis .BatchSize .PreferredMaxBytes ,
76+ }),
77+ sharedconfig .TemplateBatchTimeout (conf .Genesis .BatchTimeout .String ()),
78+ sharedconfig .TemplateIngressPolicyNames ([]string {AcceptAllPolicyKey }),
79+ sharedconfig .TemplateEgressPolicyNames ([]string {AcceptAllPolicyKey }),
80+
81+ // Policies
82+ cauthdsl .TemplatePolicy (configtx .NewConfigurationItemPolicyKey , cauthdsl .RejectAllPolicy ),
83+ cauthdsl .TemplatePolicy (AcceptAllPolicyKey , cauthdsl .AcceptAllPolicy ),
84+ },
85+
86+ systemChainItems : []* cb.ConfigurationItem {
87+ sharedconfig .TemplateChainCreationPolicyNames (DefaultChainCreationPolicyNames ),
9088 },
91- batchTimeout : conf .Genesis .BatchTimeout .String (),
9289 }
9390
9491 switch conf .Genesis .OrdererType {
9592 case ConsensusTypeSolo , ConsensusTypeSbft :
96- return & soloBootstrapper {
97- commonBootstrapper : * cbs ,
98- }
9993 case ConsensusTypeKafka :
100- return & kafkaBootstrapper {
101- commonBootstrapper : * cbs ,
102- kafkaBrokers : conf .Kafka .Brokers ,
103- }
94+ bs .minimalItems = append (bs .minimalItems , sharedconfig .TemplateKafkaBrokers (conf .Kafka .Brokers ))
10495 default :
10596 panic (fmt .Errorf ("Wrong consenter type value given: %s" , conf .Genesis .OrdererType ))
10697 }
98+
99+ return bs
100+ }
101+
102+ func (bs * bootstrapper ) TemplateItems () []* cb.ConfigurationItem {
103+ return bs .minimalItems
107104}
108105
109- func (cbs * commonBootstrapper ) genesisBlock ( minimalTemplateItems func () [] * cb. ConfigurationItem ) * cb.Block {
106+ func (bs * bootstrapper ) GenesisBlock ( ) * cb.Block {
110107 block , err := genesis .NewFactoryImpl (
111108 configtx .NewCompositeTemplate (
112- configtx .NewSimpleTemplate (minimalTemplateItems () ... ),
113- configtx .NewSimpleTemplate (cbs . makeOrdererSystemChainConfig () ... ),
109+ configtx .NewSimpleTemplate (bs . minimalItems ... ),
110+ configtx .NewSimpleTemplate (bs . systemChainItems ... ),
114111 ),
115112 ).Block (TestChainID )
116113
@@ -119,13 +116,3 @@ func (cbs *commonBootstrapper) genesisBlock(minimalTemplateItems func() []*cb.Co
119116 }
120117 return block
121118}
122-
123- // GenesisBlock returns the genesis block to be used for bootstrapping.
124- func (cbs * commonBootstrapper ) GenesisBlock () * cb.Block {
125- return cbs .genesisBlock (cbs .TemplateItems )
126- }
127-
128- // GenesisBlock returns the genesis block to be used for bootstrapping.
129- func (kbs * kafkaBootstrapper ) GenesisBlock () * cb.Block {
130- return kbs .genesisBlock (kbs .TemplateItems )
131- }
0 commit comments