@@ -19,9 +19,11 @@ package provisional
19
19
import (
20
20
"fmt"
21
21
22
+ "github.com/hyperledger/fabric/common/cauthdsl"
22
23
"github.com/hyperledger/fabric/common/configtx"
23
24
"github.com/hyperledger/fabric/common/genesis"
24
25
"github.com/hyperledger/fabric/orderer/common/bootstrap"
26
+ "github.com/hyperledger/fabric/orderer/common/sharedconfig"
25
27
"github.com/hyperledger/fabric/orderer/localconfig"
26
28
cb "github.com/hyperledger/fabric/protos/common"
27
29
ab "github.com/hyperledger/fabric/protos/orderer"
@@ -36,8 +38,6 @@ type Generator interface {
36
38
}
37
39
38
40
const (
39
- msgVersion = int32 (1 )
40
-
41
41
// ConsensusTypeSolo identifies the solo consensus implementation.
42
42
ConsensusTypeSolo = "solo"
43
43
// ConsensusTypeKafka identifies the Kafka-based consensus implementation.
@@ -53,64 +53,61 @@ const (
53
53
54
54
// AcceptAllPolicyKey is the key of the AcceptAllPolicy.
55
55
AcceptAllPolicyKey = "AcceptAllPolicy"
56
-
57
- // These values are fixed for the genesis block.
58
- lastModified = 0
59
- epoch = 0
60
56
)
61
57
62
58
// DefaultChainCreationPolicyNames is the default value of ChainCreatorsKey.
63
59
var DefaultChainCreationPolicyNames = []string {AcceptAllPolicyKey }
64
60
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
79
64
}
80
65
81
66
// New returns a new provisional bootstrap helper.
82
67
func 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 ),
90
88
},
91
- batchTimeout : conf .Genesis .BatchTimeout .String (),
92
89
}
93
90
94
91
switch conf .Genesis .OrdererType {
95
92
case ConsensusTypeSolo , ConsensusTypeSbft :
96
- return & soloBootstrapper {
97
- commonBootstrapper : * cbs ,
98
- }
99
93
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 ))
104
95
default :
105
96
panic (fmt .Errorf ("Wrong consenter type value given: %s" , conf .Genesis .OrdererType ))
106
97
}
98
+
99
+ return bs
100
+ }
101
+
102
+ func (bs * bootstrapper ) TemplateItems () []* cb.ConfigurationItem {
103
+ return bs .minimalItems
107
104
}
108
105
109
- func (cbs * commonBootstrapper ) genesisBlock ( minimalTemplateItems func () [] * cb. ConfigurationItem ) * cb.Block {
106
+ func (bs * bootstrapper ) GenesisBlock ( ) * cb.Block {
110
107
block , err := genesis .NewFactoryImpl (
111
108
configtx .NewCompositeTemplate (
112
- configtx .NewSimpleTemplate (minimalTemplateItems () ... ),
113
- configtx .NewSimpleTemplate (cbs . makeOrdererSystemChainConfig () ... ),
109
+ configtx .NewSimpleTemplate (bs . minimalItems ... ),
110
+ configtx .NewSimpleTemplate (bs . systemChainItems ... ),
114
111
),
115
112
).Block (TestChainID )
116
113
@@ -119,13 +116,3 @@ func (cbs *commonBootstrapper) genesisBlock(minimalTemplateItems func() []*cb.Co
119
116
}
120
117
return block
121
118
}
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