-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
164 lines (139 loc) · 6.1 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
/*
Notice: This file has been modified for Hyperledger Fabric SDK Go usage.
Please review third_party pinning scripts and patches for more details.
*/
package genesisconfig
import (
"time"
"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
)
const (
// Prefix identifies the prefix for the configtxgen-related ENV vars.
Prefix string = "CONFIGTX"
// The type key for etcd based RAFT consensus.
EtcdRaft = "etcdraft"
)
const (
// SampleInsecureSoloProfile references the sample profile which does not
// include any MSPs and uses solo for ordering.
SampleInsecureSoloProfile = "SampleInsecureSolo"
// SampleDevModeSoloProfile references the sample profile which requires
// only basic membership for admin privileges and uses solo for ordering.
SampleDevModeSoloProfile = "SampleDevModeSolo"
// SampleSingleMSPSoloProfile references the sample profile which includes
// only the sample MSP and uses solo for ordering.
SampleSingleMSPSoloProfile = "SampleSingleMSPSolo"
// SampleInsecureKafkaProfile references the sample profile which does not
// include any MSPs and uses Kafka for ordering.
SampleInsecureKafkaProfile = "SampleInsecureKafka"
// SampleDevModeKafkaProfile references the sample profile which requires only
// basic membership for admin privileges and uses Kafka for ordering.
SampleDevModeKafkaProfile = "SampleDevModeKafka"
// SampleSingleMSPKafkaProfile references the sample profile which includes
// only the sample MSP and uses Kafka for ordering.
SampleSingleMSPKafkaProfile = "SampleSingleMSPKafka"
// SampleDevModeEtcdRaftProfile references the sample profile used for testing
// the etcd/raft-based ordering service.
SampleDevModeEtcdRaftProfile = "SampleDevModeEtcdRaft"
// SampleSingleMSPChannelProfile references the sample profile which
// includes only the sample MSP and is used to create a channel
SampleSingleMSPChannelProfile = "SampleSingleMSPChannel"
// SampleConsortiumName is the sample consortium from the
// sample configtx.yaml
SampleConsortiumName = "SampleConsortium"
// SampleOrgName is the name of the sample org in the sample profiles
SampleOrgName = "SampleOrg"
// AdminRoleAdminPrincipal is set as AdminRole to cause the MSP role of
// type Admin to be used as the admin principal default
AdminRoleAdminPrincipal = "Role.ADMIN"
)
// TopLevel consists of the structs used by the configtxgen tool.
type TopLevel struct {
Profiles map[string]*Profile `yaml:"Profiles"`
Organizations []*Organization `yaml:"Organizations"`
Channel *Profile `yaml:"Channel"`
Application *Application `yaml:"Application"`
Orderer *Orderer `yaml:"Orderer"`
Capabilities map[string]map[string]bool `yaml:"Capabilities"`
}
// Profile encodes orderer/application configuration combinations for the
// configtxgen tool.
type Profile struct {
Consortium string `yaml:"Consortium"`
Application *Application `yaml:"Application"`
Orderer *Orderer `yaml:"Orderer"`
Consortiums map[string]*Consortium `yaml:"Consortiums"`
Capabilities map[string]bool `yaml:"Capabilities"`
Policies map[string]*Policy `yaml:"Policies"`
}
// Policy encodes a channel config policy
type Policy struct {
Type string `yaml:"Type"`
Rule string `yaml:"Rule"`
}
// Consortium represents a group of organizations which may create channels
// with each other
type Consortium struct {
Organizations []*Organization `yaml:"Organizations"`
}
// Application encodes the application-level configuration needed in config
// transactions.
type Application struct {
Organizations []*Organization `yaml:"Organizations"`
Capabilities map[string]bool `yaml:"Capabilities"`
Policies map[string]*Policy `yaml:"Policies"`
ACLs map[string]string `yaml:"ACLs"`
}
// Organization encodes the organization-level configuration needed in
// config transactions.
type Organization struct {
Name string `yaml:"Name"`
ID string `yaml:"ID"`
MSPDir string `yaml:"MSPDir"`
MSPType string `yaml:"MSPType"`
Policies map[string]*Policy `yaml:"Policies"`
// Note: Viper deserialization does not seem to care for
// embedding of types, so we use one organization struct
// for both orderers and applications.
AnchorPeers []*AnchorPeer `yaml:"AnchorPeers"`
OrdererEndpoints []string `yaml:"OrdererEndpoints"`
// AdminPrincipal is deprecated and may be removed in a future release
// it was used for modifying the default policy generation, but policies
// may now be specified explicitly so it is redundant and unnecessary
AdminPrincipal string `yaml:"AdminPrincipal"`
// SkipAsForeign indicates that this org definition is actually unknown to this
// instance of the tool, so, parsing of this org's parameters should be ignored.
SkipAsForeign bool
}
// AnchorPeer encodes the necessary fields to identify an anchor peer.
type AnchorPeer struct {
Host string `yaml:"Host"`
Port int `yaml:"Port"`
}
// Orderer contains configuration associated to a channel.
type Orderer struct {
OrdererType string `yaml:"OrdererType"`
Addresses []string `yaml:"Addresses"`
BatchTimeout time.Duration `yaml:"BatchTimeout"`
BatchSize BatchSize `yaml:"BatchSize"`
Kafka Kafka `yaml:"Kafka"`
EtcdRaft *etcdraft.ConfigMetadata `yaml:"EtcdRaft"`
Organizations []*Organization `yaml:"Organizations"`
MaxChannels uint64 `yaml:"MaxChannels"`
Capabilities map[string]bool `yaml:"Capabilities"`
Policies map[string]*Policy `yaml:"Policies"`
}
// BatchSize contains configuration affecting the size of batches.
type BatchSize struct {
MaxMessageCount uint32 `yaml:"MaxMessageCount"`
AbsoluteMaxBytes uint32 `yaml:"AbsoluteMaxBytes"`
PreferredMaxBytes uint32 `yaml:"PreferredMaxBytes"`
}
// Kafka contains configuration for the Kafka-based orderer.
type Kafka struct {
Brokers []string `yaml:"Brokers"`
}