Skip to content

Commit 9f01df5

Browse files
authored
调整格式
1 parent 28a1afb commit 9f01df5

File tree

1 file changed

+48
-29
lines changed

1 file changed

+48
-29
lines changed

README.md

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@
2424

2525

2626
## 2. 安装git
27-
>apt-get update
28-
29-
>apt-get install git
27+
``` shell
28+
apt-get update
29+
apt-get install git
30+
```
3031

3132
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/B81421F12EF749859012A426ED493736/159)
3233

3334

3435
## 3. 安装docker-ce
3536
请不要直接apt安装旧版本的docker
3637

37-
[阿里云安装docker教程](https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.5d4e1991URD8Ia)
38+
[阿里云安装docker教程](https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.5d4e1991URD8Ia)
3839

39-
```
40+
```shell
4041
# step 1: 安装必要的一些系统工具
4142
sudo apt-get update
4243
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
@@ -63,27 +64,32 @@ sudo apt-get -y install docker-ce
6364

6465

6566
ubuntu14.04系统采用不支持systemctl
66-
>service docker restart
67-
68-
重启docker服务
67+
``` shell
68+
#重启docker服务
69+
service docker restart
70+
```
6971

7072

7173
## 5. 安装hyperledger的工具和docker镜像
7274

7375
点击官方[参考文档](http://hyperledger-fabric.readthedocs.io/en/release-1.1/samples.html#binaries)
7476

75-
注意: 按照官方文档执行, 需要全局翻墙才行
77+
* 注意: 按照官方文档执行, 需要全局翻墙才行
7678

7779
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/BB783CDD52B842A4A1BDAE19923FBA5E/225)
7880

81+
* 安装完检查目录结构和docker镜像:
7982

80-
安装完检查目录结构和docker镜像:
8183
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/AC3A8997B51C4C65AF9E1D4CF7F3FCD1/232)
8284

8385

8486
## 6. 下载官方的示例代码 fabric sample
8587

86-
>git clone https://github.com/hyperledger/fabric-samples.git
88+
``` shell
89+
git clone https://github.com/hyperledger/fabric-samples.git
90+
```
91+
92+
8793

8894
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/DA434F1251A342F99E1BACC24C208524/240)
8995

@@ -97,7 +103,7 @@ ubuntu14.04系统采用不支持systemctl
97103

98104
## 8. 启动fabric ledger的第一个网络
99105
运行如下命令:
100-
```
106+
```shell
101107
#1. 配置环境变量, fabirc的二进制工具
102108
export PATH=/root/bin:$PATH
103109
#2. 生成hyperledger fabric的各种区块链配置
@@ -119,7 +125,7 @@ chmod +x /usr/local/bin/docker-compose
119125
>/etc/resolv.conf
120126
注释掉 options timeout:2 attempts:3 rotate single-request-reopen
121127
重新执行
122-
```
128+
```shell
123129
./byfn.sh -m down
124130
./byfn.sh -m up
125131
```
@@ -136,21 +142,26 @@ chmod +x /usr/local/bin/docker-compose
136142
>看到上面的截图,说明你的开发环境已经准备好, 接下来我们就可以搭建自己的组织结构,编写nodejs的链码了.
137143
138144

139-
## 11. 停止网络请使用命令
140145

141-
> ./byfn.sh -m down
146+
## 11. 停止网络请使用命令
142147

148+
``` shell
149+
./byfn.sh -m down
150+
```
143151

144152

145153

146154
## 12. 切换到basic-network目录
155+
147156
来到fabirc-sample目录的basic-network文件夹
148157

158+
159+
149160
## 13. 修改 basic-network的docker-compose.yml
161+
150162
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/14483191ED1C41A7991A62E954BE79BD/298)
151163
> 说明: 启用开发者模式,这样加快调试部署,减少资源开销
152-
开启7052端口, 开发模式下不使用tls会减少出错的概率,生产环境需要启用tls
153-
164+
> 开启7052端口, 开发模式下不使用tls会减少出错的概率,生产环境需要启用tls
154165
155166

156167

@@ -163,13 +174,14 @@ chmod +x /usr/local/bin/docker-compose
163174

164175
## 15. 启动脚本 'start.h'
165176
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/EAD0F21FA9394D5CB8E6394758C2BB26/326)
166-
可以看到启动了ca节点,peer节点,order节点,cli节点和couchdb,创建了channel,peer加入了channel
177+
178+
> 可以看到启动了ca节点,peer节点,order节点,cli节点和couchdb,创建了channel,peer加入了channel
167179
168180

169181
## 16. 查看状态
170182
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/FAF8C3A10DF14B47B8AF757A6FBE8989/337)
171183

172-
```
184+
```shell
173185
docker ps
174186
#可以看到当前运行的docker容器, peer,order,couchdb,ca,cli节点
175187
docker exec -it bash
@@ -179,19 +191,21 @@ peer channel list
179191
```
180192

181193

194+
182195
## 17. chaincode编写需要使用nodejs
196+
183197
请安装>8.0版本的nodejs
184198

185199
官网连接 [点我直达](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
186-
```
200+
```shell
187201
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
188202
sudo apt-get install -y nodejs
189203
```
190204

191205

192206

193207
## 18.编写nodejs的chaincode
194-
```
208+
```shell
195209
#1.创建mycc文件夹
196210
mkdir mycc
197211
#2. 初始化package.json文件
@@ -207,7 +221,7 @@ npm install --save fabric-shim --registry=https://registry.npm.taobao.org
207221

208222

209223
## 19. 编写nodejs链码
210-
```
224+
```javascript
211225
const shim = require('fabric-shim');
212226
const Chaincode = class{
213227
//链码初始化操作
@@ -242,7 +256,7 @@ shim.start(new Chaincode());
242256

243257
## 20. 把chaincode注册给peer
244258
他们之间通过grcp协议通信
245-
```
259+
```shell
246260
CORE_CHAINCODE_ID_NAME="mycc:v0" npm start -- --peer.address grpc://192.168.0.1:7052
247261
```
248262
![image](https://note.youdao.com/yws/public/resource/95c087db9c2f4249616a4058c521ca13/xmlnote/94BCB93C2A2C4187865814C0844C15AD/390)
@@ -252,7 +266,7 @@ CORE_CHAINCODE_ID_NAME="mycc:v0" npm start -- --peer.address grpc://192.168.0.1
252266
## 21. 在peer上install安装链码
253267
这是peer上chaincode的生命周期
254268

255-
```
269+
```shell
256270
CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp peer chaincode install -l node -n mycc -v v0 -p /opt/gopath/src/github.com/mycc/
257271

258272
```
@@ -262,7 +276,7 @@ CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/
262276

263277
## 22. 在peer上实例化链码
264278

265-
```
279+
```shell
266280
CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp peer chaincode instantiate -l node -n mycc -v v0 -C mychannel -c '{"args":["init","zzh","100","czbk","100"]}' -o 192.168.0.1:7050
267281
```
268282

@@ -272,7 +286,7 @@ CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/
272286
## 23. 测试链码调用
273287

274288

275-
```
289+
```shell
276290
CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp peer chaincode invoke -n mycc -C mychannel -c '{"args":["query","zzh"]}' -o 192.168.0.1:7050
277291
```
278292

@@ -287,11 +301,16 @@ CORE_PEER_LOCALMSPID=Org1MSP CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/
287301
试着自己实现一下transfer方法吧
288302

289303
## 25. 停止网络使用
290-
> ./stop.sh ./teardown.sh
304+
``` shell
305+
./stop.sh ./teardown.sh
306+
```
307+
308+
291309

292310

293311
## 26. 查看环境是否清理干净
294-
> docker ps 无内容就说明环境清理干净
312+
``` shell
313+
docker ps
295314
```
296315

297-
```
316+
> 无内容就说明环境清理干净

0 commit comments

Comments
 (0)