多链码部署
现在,我们的chaincode里面
有3个文件夹,3个链码
看下tree
abc@abc:~/workspace/dairy/test$ tree
.
├── dairy
│ └── dairy.go
├── machining
│ └── machining.go
└── sale
└── sale.go
3 directories, 3 files
启动一下试试
看下结果
abc@abc:~/workspace/dairydemo$ ./start.sh up
启动 orderer 组织节点...
Creating orderer.trace.com ... done
启动 dairy 组织节点...
WARNING: Found orphan containers (orderer.trace.com) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating peer0.dairy.trace.com ... done
Creating peer1.dairy.trace.com ... done
Creating cli-dairy ... done
启动 machining 组织节点...
WARNING: Found orphan containers (cli-dairy, peer1.dairy.trace.com, peer0.dairy.trace.com, orderer.trace.com) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating peer0.machining.trace.com ... done
Creating peer1.machining.trace.com ... done
Creating cli-machining ... done
启动 sale 组织节点...
WARNING: Found orphan containers (cli-machining, peer0.machining.trace.com, peer1.machining.trace.com, cli-dairy, peer1.dairy.trace.com, peer0.dairy.trace.com, orderer.trace.com) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating peer0.sale.trace.com ... done
Creating peer1.sale.trace.com ... done
Creating cli-sale ... done
==========查看进程==========
Name Command State Ports
------------------------------------------------------------
orderer.trace.com orderer Up 0.0.0.0:7050->7050/tcp
Name Command State Ports
------------------------------------------------------------------------------------------------
cli-dairy /bin/bash Up
peer0.dairy.trace.com peer node start Up 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp
peer1.dairy.trace.com peer node start Up 0.0.0.0:7151->7051/tcp, 0.0.0.0:7153->7053/tcp
Name Command State Ports
----------------------------------------------------------------------------------------------------
cli-machining /bin/bash Up
peer0.machining.trace.com peer node start Up 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp
peer1.machining.trace.com peer node start Up 0.0.0.0:8151->7051/tcp, 0.0.0.0:8153->7053/tcp
Name Command State Ports
-----------------------------------------------------------------------------------------------
cli-sale /bin/bash Up
peer0.sale.trace.com peer node start Up 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp
peer1.sale.trace.com peer node start Up 0.0.0.0:9151->7051/tcp, 0.0.0.0:9153->7053/tcp
然后进入客户端
docker exec -it cli-dairy bash
abc@abc:~/workspace/dairydemo$ docker exec -it cli-dairy bash
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer#
然后创建通道
tlsfile=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/trace.com/msp/tlscacerts/tlsca.trace.com-cert.pem
peer channel create -o orderer.trace.com:7050 --tls --cafile $tlsfile -c tracechannel -f ./channel-artifacts/channel.tx
看下执行和结果
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer# tlsfile=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/trace.com/msp/tlscacerts/tlsca.trace.com-cert.pem
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer# ls
channel-artifacts crypto
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel create -o orderer.trace.com:7050 --tls --cafile $tlsfile -c tracechannel -f ./channel-artifacts/channel.tx
2019-04-15 08:57:15.391 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-04-15 08:57:15.490 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2019-04-15 08:57:15.494 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2019-04-15 08:57:15.698 UTC [cli/common] readBlock -> INFO 004 Received block: 0
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer#
通道创建成功
然后加入通道
peer channel join -b tracechannel.block
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b tracechannel.block
2019-04-15 08:58:57.212 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-04-15 08:58:57.428 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
验证一下
peer channel list
root@139f9ea6ead9:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel list
2019-04-15 08:59:32.387 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Channels peers has joined:
tracechannel