-
Notifications
You must be signed in to change notification settings - Fork 1
/
example01.sh
executable file
·189 lines (166 loc) · 4.94 KB
/
example01.sh
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
set -e
source $(dirname $0)/common.sh
curDir=$PWD
trap cleanup EXIT
function cleanup {
cd $curDir
}
ChannelName=my-ch
CCName=my-cc
fabricDir=$GOPATH/src/github.com/hyperledger/fabric/
artifactsDir=/tmp/$(basename $0).mat/
if test -d $artifactsDir
then
rm -rf $artifactsDir
fi
mkdir $artifactsDir
ordererOrg=myordererorg
applicationOrg=myapplicationorg
ordererOrgDir=$artifactsDir/crypto-config/ordererOrganizations/$ordererOrg
applicationOrgDir=$artifactsDir/crypto-config/peerOrganizations/$applicationOrg
genBlockMain=$artifactsDir/$ChannelName.block
ordBlockMain=$artifactsDir/$ChannelName-orderer.block
genTransMain=$artifactsDir/$ChannelName-channel.tx
CONFIGTXGEN_CMD=$fabricDir/.build/bin/configtxgen
CONFIGTXLTR_CMD=$fabricDir/.build/bin/configtxlator
PEER_CMD=$fabricDir/.build/bin/peer
CRYPTOGEN_CMD=$fabricDir/.build/bin/cryptogen
CONFIGTXLTR_CMD=$fabricDir/.build/bin/configtxlator
configtxgenFile=$artifactsDir/configtx.yaml
cat <<- EOF > $configtxgenFile
---
Organizations:
- &OrdererOrg
Name: $ordererOrg
ID: $ordererOrg
MSPDir: $ordererOrgDir/msp
Policies:
Readers:
Type: Signature
Rule: "OR('$ordererOrg.member')"
Writers:
Type: Signature
Rule: "OR('$ordererOrg.member')"
Admins:
Type: Signature
Rule: "OR('$ordererOrg.admin')"
- &$applicationOrg
Name: $applicationOrg
ID: $applicationOrg
MSPDir: $applicationOrgDir/msp
Policies:
Readers:
Type: Signature
Rule: "OR('$applicationOrg.admin', '$applicationOrg.peer', '$applicationOrg.client')"
Writers:
Type: Signature
Rule: "OR('$applicationOrg.admin', '$applicationOrg.client')"
Admins:
Type: Signature
Rule: "OR('$applicationOrg.admin')"
AnchorPeers:
- Host: $applicationOrg
Port: 7051
Capabilities:
Global: &ChannelCapabilities
V1_1: true
Orderer: &OrdererCapabilities
V1_1: true
Application: &ApplicationCapabilities
V1_2: true
Application: &ApplicationDefaults
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ApplicationCapabilities
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- $ordererOrg:7050
BatchTimeout: 10ms
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
Capabilities:
<<: *OrdererCapabilities
Channel: &ChannelDefaults
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ChannelCapabilities
Profiles:
TwoOrgsOrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *$applicationOrg
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *$applicationOrg
EOF
cryptogenCfgFile=$artifactsDir/crypto-config.yaml
cat <<- EOF > $cryptogenCfgFile
OrdererOrgs:
- Name: $ordererOrg
Domain: $ordererOrg
Specs:
- Hostname: orderer
CommonName: orderer
PeerOrgs:
- Name: $applicationOrg
Domain: $applicationOrg
EnableNodeOUs: true
Specs:
- Hostname: peer
CommonName: peer
Users:
Count: 1
EOF
cd $artifactsDir
runStep $CRYPTOGEN_CMD generate --config=$cryptogenCfgFile
cd $curDir
# generating genesis block (main channel)
runStep $CONFIGTXGEN_CMD -profile TwoOrgsOrdererGenesis -outputBlock $ordBlockMain --configPath $artifactsDir
echo "$CONFIGTXLTR_CMD proto_decode --input $ordBlockMain --type common.Block | jq .data.data[0].payload.data.config.channel_group.groups.Consortiums.groups.SampleConsortium.groups.${applicationOrg}.values"
echo "$CONFIGTXLTR_CMD proto_decode --input $ordBlockMain --type common.Block | jq .data.data[0].payload.data.config.channel_group.groups.Orderer.groups.${ordererOrg}.values"