本文描述fabric-java-sdk的End2endIT在阿里云服务器和本地如何测试,测试环境如下:
阿里云服务器centos7.4,安装过程可以参考centos7安装fabric
建议给阿里云服务器配置弹性公网IP,在测试时可以租用按时付费的阿里云以节省费用。按时付费的阿里云在重启服务器后会变更公网IP。

Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.2, build 1110ad0
go version go1.11.4 linux/amd64
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
node -v v9.9.0
npm -v 6.5.0

本地运行环境win10

#java环境 java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
#maven环境 mvn -v
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: C:\apache-maven-3.5.4\bin\..
Java version: 1.8.0_31, vendor: Oracle Corporation, runtime: C:\javaSE1.8\jdk1.8\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
#eclipse版本
Mars.1 Release (4.5.1)

End2endIT实现了如下功能:

  1. 使用Fabric ca注册和加入用户
  2. 构造channel
  3. 安装链码chaincode
  4. 实例化链码
  5. 执行链码
  6. 查询channel中的区块信息
  7. 链码事件监听器用法
  8. 遍历区块信息

测试步骤如下:

  1. 服务器下载fabric-java-sdk并运行fabric.sh脚本启动fabric网络;
  2. 本地环境eclipse导入fabric-java-sdk,测试End2endIT。

1、启动fabric网络

1.1、下载fabric-java-sdk

#运行前避免被其他fabric干扰,删除运行的docker并附带其镜像
docker rm $(docker ps -aq)
docker rmi -f $(docker images -q)
#执行如下命令确保docker和images清空
docker ps -a
docker images
#我们在/home/yigou路径下新建fabric-1.3.0目录并下载源码,切换到1.3.0
cd /home/yigou
mkdir fabric-1.3.0
cd fabric-1.3.0
git clone https://github.com/hyperledger/fabric-sdk-java.git
cd fabric-sdk-java
git tag
git checkout -b v1.3.0
cd src/test/fixture/sdkintegration

1.2、启动fabric网络

启动网络之前,由于centos7.4的缘故,需要修改docker-compose.yaml文件,在所有environment下面添加如下命令,参考下图。

      - GODEBUG=netdns=go

在这里插入图片描述

fabric.sh脚本说明
1)脚本命令包含了:./fabric.sh up 强制重新创建网络(默认会启动)。
./fabric.sh start启动
./fabric.sh stop停止
./fabric.sh clean清理生成的docker容器;
实际上fabric.sh只是对docker-compose命令的简单封装。
2)每次使用后,如果重新跑需要执行clean命令清除掉生成的docker容器和其他临时文件。

执行如下命令,启动fabric网络。

 fabric.sh up

至此,一个包含1个orderer;4个peer;2个fabric-ca-server的网络(定义在docker-compose.yaml)启动成功,通过如下命令我们可以看到。

[root@bc1 ~]# docker ps -a
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
451c232d6d01        hyperledger/fabric-peer      "peer node start"        12 minutes ago      Up 12 minutes       0.0.0.0:8056->8056/tcp, 0.0.0.0:8058->8058/tcp   peer1.org2.example.com
edc19ad01ea5        hyperledger/fabric-peer      "peer node start"        12 minutes ago      Up 12 minutes       0.0.0.0:7056->7056/tcp, 0.0.0.0:7058->7058/tcp   peer1.org1.example.com
990833ad5196        hyperledger/fabric-peer      "peer node start"        12 minutes ago      Up 12 minutes       0.0.0.0:8051->8051/tcp, 0.0.0.0:8053->8053/tcp   peer0.org2.example.com
1cba3434e734        hyperledger/fabric-peer      "peer node start"        12 minutes ago      Up 12 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.example.com
a1fbf5361249        hyperledger/fabric-ca        "sh -c 'mkdir -p /et…"   12 minutes ago      Up 12 minutes       0.0.0.0:7054->7054/tcp                           ca_peerOrg1
10d463eb0d6e        hyperledger/fabric-ca        "sh -c 'mkdir -p /et…"   12 minutes ago      Up 12 minutes       0.0.0.0:8054->7054/tcp                           ca_peerOrg2
56943fccc47c        hyperledger/fabric-orderer   "orderer"                12 minutes ago      Up 12 minutes       0.0.0.0:7050->7050/tcp                           orderer.example.com
04f6ec65b641        hyperledger/fabric-tools     "/usr/local/bin/conf…"   12 minutes ago      Up 12 minutes       0.0.0.0:7059->7059/tcp                           configtxlator

如果你想查看某个docker具体的日志,可以通过如下命令查看

#56943fccc47c是CONTAINER ID ,通过docker ps命令可以查看
docker logs --details -f 56943fccc47c        

2、运行End2endIT

通过github下载官方源码,导入eclipse中。
需要注意如下两点:
1、如果遇到如下错误,请删除.project和 .classpath 文件再次导入。

Failed to read the project description file (.project) for 'fabric-sdk-java'. 
The file has been changed on disk, and it now contains invalid information. 
The project will not function properly until the description file is restored to a valid state.

2、修改TestConfig文件中的LOCALHOST,变更为阿里云服务器外网地址。
TestConfig源码
使用maven,输入test -Dtest=End2endIT(参考下图),运行即可看到程序执行效果。
在这里插入图片描述
结果日志:

RUNNING: End2endIT.

***** Enrolling Users *****
2019-01-22 01:52:02,554 main INFO  HFCAClient:587 - CA Name: ca0, Version: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNRekNDQWVxZ0F3SUJBZ0lSQU0vdmFEdlBzeUlpQzlodm41bm5SOEF3Q2dZSUtvWkl6ajBFQXdJd2N6RUwKTUFrR0ExVUVCaE1DVlZNeEV6QVJCZ05WQkFnVENrTmhiR2xtYjNKdWFXRXhGakFVQmdOVkJBY1REVk5oYmlCRwpjbUZ1WTJselkyOHhHVEFYQmdOVkJBb1RFRzl5WnpFdVpYaGhiWEJzWlM1amIyMHhIREFhQmdOVkJBTVRFMk5oCkxtOXlaekV1WlhoaGJYQnNaUzVqYjIwd0hoY05NVGd3TWpJMU1USTBNekk1V2hjTk1qZ3dNakl6TVRJME16STUKV2pCek1Rc3dDUVlEVlFRR0V3SlZVekVUTUJFR0ExVUVDQk1LUTJGc2FXWnZjbTVwWVRFV01CUUdBMVVFQnhNTgpVMkZ1SUVaeVlXNWphWE5qYnpFWk1CY0dBMVVFQ2hNUWIzSm5NUzVsZUdGdGNHeGxMbU52YlRFY01Cb0dBMVVFCk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+LPjLye6/RYlejeNegmSePueBMhOctYiRAogP3UpF6MJUiwgP1WAEdcEUmA1qBzM/pnh/P4DvTClVNsSII0ME/JUvx2G/KanqXhHSdiOPO8JMvl/oT9j86NE5acMKogBCiAkGHyPPIpfZ62j37rU+vuyhyVn3GTzHxzfENb4L81d9hIg4lovQafbr+EQ8oOgJNQYJTNoxrwt03gX0KoS351tA9AaIAprAFVW8Rj/oz5qv8EgezttuHVW6CeYxhClVaUXgkv8IiCB5IQt3kHBcfaLZ0G6T07NcgX0yEcLq/SCjjIzC+OMITJECiBjX+SptFK5yiKrp6p2unJEQzicZrOl7pcjQaYCRscHxBIgNa9BFzQiJmywsmJlMcjSexW66XrrJZzTGZIGjeuiobU6RAogiyMMfc2QIHR94xmd+qIfFFeu8C0G3x/as3asLSH63YcSIEPbCHzdb/sMxS5h42sPx+bhLbJ0UzYMapdOKilxyluFQiC+JXB0Nrg+JUDkXOO30VuNa1OWTaY+uui66lvI59+s/EogS5zQNR8QLbjptQUWittI672tran5xUvtidx7QeTSjQVSIHRZz7ANrFN/racCNVLnIrCqzxKU+QGje3+AuKvFasmy, issuerRevocationPublicKey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUhZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUNJRFlnQUVwS25UUmEwSkt6bXl6SzBkay8rcXRJUC81Z3U1YlJqMgpreWlZNFl3RVk0djgxU20yclhXTnlHQ2Fqei81ak5Gd3UzMnZGTG9iSHNuU1ZKaTdKNVA5UGlwOTRPQ1dwUHYyCi90a20vYldmZSsrbmIxNjBCTE1LMUFjYURjTHRWS1RFCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
2019-01-22 01:52:02,559 main INFO  SampleStore:91 - Could not find the file "C:\Users\jiang\AppData\Local\Temp\HFCSampletest.properties"
2019-01-22 01:52:02,561 main INFO  SampleStore:91 - Could not find the file "C:\Users\jiang\AppData\Local\Temp\HFCSampletest.properties"
2019-01-22 01:52:02,927 main IN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iC+JXB0Nrg+JUDkXOO30VuNa1OWTaY+uui66lvI59+s/EogS5zQNR8QLbjptQUWittI672tran5xUvtidx7QeTSjQVSIHRZz7ANrFN/racCNVLnIrCqzxKU+QGje3+AuKvFasmy, issuerRevocationPublicKey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUhZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUNJRFlnQUVwS25UUmEwSkt6bXl6SzBkay8rcXRJUC81Z3U1YlJqMgpreWlZNFl3RVk0djgxU20yclhXTnlHQ2Fqei81ak5Gd3UzMnZGTG9iSHNuU1ZKaTdKNVA5UGlwOTRPQ1dwUHYyCi90a20vYldmZSsrbmIxNjBCTE1LMUFjYURjTHRWS1RFCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
2019-01-22 01:52:02,928 main INFO  HFCAClient:1535 - CA Version: 1.4.0
2019-01-22 01:52:03,315 main INFO  HFCAClient:587 - CA Name: , Version: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNRakNDQWVtZ0F3SUJBZ0lRQTUxUzVhVjhPRktUREVrQURhL0I0VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTWk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NaTVsZUdGdGNHeGxMbU52YlRBZUZ3MHhPREF5TWpVeE1qUXpNamxhRncweU9EQXlNak14TWpRek1qbGEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3lMbVY0WVcxd2JHVXVZMjl0TVJ3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Ah3B2lSWCpzDJliL7wATU9OIvjnZ4VmzQPX8xha1SIIQ6XWpZn5NGEMPdfoKXn262cOdbyiKjTLa+4nXEc0wy, issuerRevocationPublicKey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUhZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUNJRFlnQUVBa3hPTmdXRzErL0Q0dG5pU0J3Q09adm5UZ1pmT3ZzZApBSWxOWWpmbXc2VUtvNEVFQ0liYmlob2d3eURFL3ZlZmlrRFNwOUMyNmtrY0dmOTErMEZVck9JTCszMk02M0dBCi8vejlnTlBWZDFSYmFFbmllMENNc2JsV2pnRTVacTdXCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
2019-01-22 01:52:03,593 main INFO  HFCAClient:1535 - CA Version: 1.4.0
Constructing channel foo
Created channel foo
2019-01-22 01:52:06,388 main INFO  Channel:772 - Channel{id: 3, name: foo} joining Peer{ id: 5, name: peer0.org1.example.com, channelName: null, url: grpc://39.96.74.133:7051}.
2019-01-22 01:52:06,625 main INFO  Channel:804 - Peer Peer{ id: 5, name: peer0.org1.example.com, channelName: foo, url: grpc://39.96.74.133:7051} joined into channel Channel{id: 3, name: foo}
Peer peer0.org1.example.com joined channel foo
2019-01-22 01:52:06,627 main INFO  Channel:772 - Channel{id: 3, name: foo} joining Peer{ id: 8, name: peer1.org1.example.com, channelName: null, url: grpc://39.96.74.133:7056}.
2019-01-22 01:52:06,816 main INFO  Channel:804 - Peer Peer{ id: 8, name: peer1.org1.example.com, channelName: foo, url: grpc://39.96.74.133:7056} joined into channel Channel{id: 3, name: foo}
Peer peer1.org1.example.com joined channel foo
2019-01-22 01:52:07,106 main INFO  Channel:1149 - Channel Channel{id: 3, name: foo} eventThread started shutdown: false  thread: null 
Finished initialization channel foo
2019-01-22 01:52:07,178 pool-1-thread-1 INFO  Channel:5220 - Channel foo eventThread shutting down. shutdown: true  thread: pool-1-thread-1 
2019-01-22 01:52:07,376 main INFO  Channel:1149 - Channel Channel{id: 16, name: foo} eventThread started shutdown: false  thread: null 
Running channel foo
Creating install proposal
Sending install proposal
2019-01-22 01:52:09,077 main INFO  InstallProposalBuilder:244 - Installing 'example_cc_go::github.com/example_cc::1' language Go chaincode from directory: 'D:\code\fabric-sdk-java\src\test\fixture\sdkintegration\gocc\sample1\src\github.com\example_cc' with source location: 'src\github.com\example_cc'. chaincodePath:'github.com/example_cc'
Successful install proposal response Txid: 875a8387160e748d6183b1762d98817202179c9063fe89a5cac5e259fb26b47a from peer peer1.org1.example.com
Successful install proposal response Txid: 875a8387160e748d6183b1762d98817202179c9063fe89a5cac5e259fb26b47a from peer peer0.org1.example.com
Received 2 install proposal responses. Successful+verified: 2 . Failed: 0
Sending instantiateProposalRequest to all peers with arguments: a and b set to 100 and 200 respectively
Succesful instantiate proposal response Txid: 38a3e60ff1625ebacb1fa8f409fe3cf000b0f3dba1ef2f84f70df9e3dfcb1f47 from peer peer1.org1.example.com
Succesful instantiate proposal response Txid: 38a3e60ff1625ebacb1fa8f409fe3cf000b0f3dba1ef2f84f70df9e3dfcb1f47 from peer peer0.org1.example.com
Received 2 instantiate proposal responses. Successful+verified: 2 . Failed: 0
Sending instantiateTransaction to orderer with a and b set to 100 and 200 respectively
Finished instantiate transaction with transaction id 38a3e60ff1625ebacb1fa8f409fe3cf000b0f3dba1ef2f84f70df9e3dfcb1f47
sending transactionProposal to all peers with arguments: move(a,b,100)
Successful transaction proposal response Txid: 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787 from peer peer1.org1.example.com
Successful transaction proposal response Txid: 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787 from peer peer0.org1.example.com
Received 2 transaction proposal responses. Successful+verified: 2 . Failed: 0
Successfully received transaction proposal responses.
Sending chaincode transaction(move a,b,100) to orderer.
Finished transaction with transaction id 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787
Now query chaincode for the value of b.
RECEIVED Chaincode event with handle: CHAINCODE_EVENTS_HANDLE09fbe365-d207-4144-8f63-022409d5bb7aCHAINCODE_EVENTS_HANDLE, chaincode Id: example_cc_go, chaincode event name: event, transaction id: 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787, event payload: "!", from eventhub: peer1.org1.example.com
RECEIVED Chaincode event with handle: CHAINCODE_EVENTS_HANDLE09fbe365-d207-4144-8f63-022409d5bb7aCHAINCODE_EVENTS_HANDLE, chaincode Id: example_cc_go, chaincode event name: event, transaction id: 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787, event payload: "!", from eventhub: peer0.org1.example.com
Query payload of b from peer peer1.org1.example.com returned 300
Query payload of b from peer peer0.org1.example.com returned 300
Channel info for : foo
Channel height: 3
Chain current block hash: d71b84fe50d844c7232716122377dc6e0f15d5357aa073a310ab54c59e5a33de
Chainl previous block hash: cacd110b67a4dea9ffa2a7de7b015f6df9a893a2cae25bf79f387e2a5fe17911
queryBlockByNumber returned correct block with blockNumber 2 
 previous_hash cacd110b67a4dea9ffa2a7de7b015f6df9a893a2cae25bf79f387e2a5fe17911
queryBlockByHash returned block with blockNumber 1
queryBlockByTxID returned block with blockNumber 2
QueryTransactionByID returned TransactionInfo: txID 301ad75f6b7a56ab3668a2905d64c3eb32c1a48bf2ec75385346e7a2168c6787
     validation code 0
Running for Channel foo done


Constructing channel bar
2019-01-22 01:52:41,645 pool-1-thread-1 INFO  Channel:5220 - Channel foo eventThread shutting down. shutdown: true  thread: pool-1-thread-1 
Created channel bar
2019-01-22 01:52:41,892 main INFO  Channel:772 - Channel{id: 32, name: bar} joining Peer{ id: 34, name: peer0.org2.example.com, channelName: null, url: grpc://39.96.74.133:8051}.
2019-01-22 01:52:42,053 main INFO  Channel:804 - Peer Peer{ id: 34, name: peer0.org2.example.com, channelName: bar, url: grpc://39.96.74.133:8051} joined into channel Channel{id: 32, name: bar}
Peer peer0.org2.example.com joined channel bar
2019-01-22 01:52:42,054 main INFO  Channel:772 - Channel{id: 32, name: bar} joining Peer{ id: 37, name: peer1.org2.example.com, channelName: null, url: grpc://39.96.74.133:8056}.
2019-01-22 01:52:42,199 main INFO  Channel:804 - Peer Peer{ id: 37, name: peer1.org2.example.com, channelName: bar, url: grpc://39.96.74.133:8056} joined into channel Channel{id: 32, name: bar}
Peer peer1.org2.example.com joined channel bar
2019-01-22 01:52:42,399 main INFO  Channel:1149 - Channel Channel{id: 32, name: bar} eventThread started shutdown: false  thread: null 
Finished initialization channel bar
2019-01-22 01:52:42,401 pool-1-thread-1 INFO  Channel:5220 - Channel bar eventThread shutting down. shutdown: true  thread: pool-1-thread-1 
2019-01-22 01:52:42,587 main INFO  Channel:1149 - Channel Channel{id: 45, name: bar} eventThread started shutdown: false  thread: null 
Running channel bar
Creating install proposal
Sending install proposal
2019-01-22 01:52:44,388 main INFO  InstallProposalBuilder:258 - Installing 'example_cc_go::github.com/example_cc::1'  Go chaincode chaincodePath:'github.com/example_cc' from input stream
Successful install proposal response Txid: 7f898be8c32f7d29da52bb294e2cf623a8d3718e47333d85efc0fd93106a5667 from peer peer1.org2.example.com
Successful install proposal response Txid: 7f898be8c32f7d29da52bb294e2cf623a8d3718e47333d85efc0fd93106a5667 from peer peer0.org2.example.com
Received 2 install proposal responses. Successful+verified: 2 . Failed: 0
Sending instantiateProposalRequest to all peers with arguments: a and b set to 100 and 300 respectively
Succesful instantiate proposal response Txid: 552d9263a9c27b7773d4d6b2576e492cb9ca2b2cb5867b6f7a8faa91a0f95455 from peer peer1.org2.example.com
Succesful instantiate proposal response Txid: 552d9263a9c27b7773d4d6b2576e492cb9ca2b2cb5867b6f7a8faa91a0f95455 from peer peer0.org2.example.com
Received 2 instantiate proposal responses. Successful+verified: 2 . Failed: 0
Sending instantiateTransaction to orderer with a and b set to 100 and 300 respectively
Finished instantiate transaction with transaction id 552d9263a9c27b7773d4d6b2576e492cb9ca2b2cb5867b6f7a8faa91a0f95455
sending transactionProposal to all peers with arguments: move(a,b,100)
Successful transaction proposal response Txid: 6f6cf00d947b099672464f5441f4f4abc15b325538cbb31e1aca0c4d5ba1f061 from peer peer1.org2.example.com
Successful transaction proposal response Txid: 6f6cf00d947b099672464f5441f4f4abc15b325538cbb31e1aca0c4d5ba1f061 from peer peer0.org2.example.com
Received 2 transaction proposal responses. Successful+verified: 2 . Failed: 0
Successfully received transaction proposal responses.
Sending chaincode transaction(move a,b,100) to orderer.
Finished transaction with transaction id 6f6cf00d947b099672464f5441f4f4abc15b325538cbb31e1aca0c4d5ba1f061
Now query chaincode for the value of b.
Query payload of b from peer peer1.org2.example.com returned 400
Query payload of b from peer peer0.org2.example.com returned 400
Channel info for : bar
Channel height: 3
Chain current block hash: 17bcbc34e6001b61e51b8029a78f878512366d9112b0d6927ce156268c4c404a
Chainl previous block hash: 0f201de1747c6423e824b929687b77c87f2a526389bd3cccb8acd497206e19bc
queryBlockByNumber returned correct block with blockNumber 2 
 previous_hash 0f201de1747c6423e824b929687b77c87f2a526389bd3cccb8acd497206e19bc
queryBlockByHash returned block with blockNumber 1
queryBlockByTxID returned block with blockNumber 2
QueryTransactionByID returned TransactionInfo: txID 6f6cf00d947b099672464f5441f4f4abc15b325538cbb31e1aca0c4d5ba1f061
     validation code 0
Running for Channel bar done

Traverse the blocks for chain bar 
current block number 2 has data hash: 99e6f61ae3a9047b34e7c3258c367efb44530373ccccd8825e95f333368646cf
current block number 2 has previous hash id: 0f201de1747c6423e824b929687b77c87f2a526389bd3cccb8acd497206e19bc
current block number 2 has calculated block hash is 17bcbc34e6001b61e51b8029a78f878512366d9112b0d6927ce156268c4c404a
current block number 2 has 1 envelope count:
  Transaction number 1 has transaction id: 6f6cf00d947b099672464f5441f4f4abc15b325538cbb31e1aca0c4d5ba1f061
  Transaction number 1 has channel id: bar
  Transaction number 1 has epoch: 0
  Transaction number 1 has transaction timestamp: 一月 22,  2019  09:53:08 上午
  Transaction number 1 has type id: TRANSACTION_ENVELOPE
  Transaction number 1 has nonce : 7cb633e459c8c3f47d33b0da177f87ff8edee6f013a5e9c8
  Transaction number 1 has submitter mspid: Org2MSP,  certificate: -----BEGIN CERTIFICATE-----
MIICjjCCAjWgAwIBAgIUFNrLa8UZkFM0YKM/6szDkdbFydkwCgYIKoZIzj0EAwIw
czELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh
biBGcmFuY2lzY28xGTAXBgNVBAoTEG9yZzIuZXhhbXBsZS5jb20xHDAaBgNVBAMT
E2NhLm9yZzIuZXhhbXBsZS5jb20wHhcNMTkwMTIyMDE0NzAwWhcNMjAwMTIyMDE1
MjAwWjBCMTAwDQYDVQQLEwZjbGllbnQwCwYDVQQLEwRvcmcxMBIGA1UECxMLZGVw
YXJ0bWVudDExDjAMBgNVBAMTBXVzZXIxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD
QgAEW+nAoZcYZw0WWRc7TLc42EgkKgjE1wD4PY8WppVCCEtt84JRaT6Ct2GQNmiJ
zqoeviYC/xpRSobMhl9tbpxtM6OB1zCB1DAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0T
AQH/BAIwADAdBgNVHQ4EFgQUtMxN0YotVbrS39neFWVvBL7MoIMwKwYDVR0jBCQw
IoAgeyt2U8RRLWzpU144FAY19Tm9ihML5UrJT34TG3Wg8j4waAYIKgMEBQYHCAEE
XHsiYXR0cnMiOnsiaGYuQWZmaWxpYXRpb24iOiJvcmcxLmRlcGFydG1lbnQxIiwi
aGYuRW5yb2xsbWVudElEIjoidXNlcjEiLCJoZi5UeXBlIjoiY2xpZW50In19MAoG
CCqGSM49BAMCA0cAMEQCIE1S2nPYL5v+EEE9qCCeSxQKI4OmjONB/9eXFSjbr73y
AiAKz29yNNPxfu8w/UlFlhC8qkKF8HanuQc/232VcO+zNA==
-----END CERTIFICATE-----

  Transaction number 1 has 1 actions
  Transaction number 1 isValid true
  Transaction number 1 validation code 0
   Transaction action 1 has response status 222
   Transaction action 1 has response message bytes as string: 
   Transaction action 1 has 2 endorsements
Endorser 0 signature: 3045022100d0f4cf8419dd5ab49eef069e10792000de44a88148798c1d5f656462c2ff8c9002202d91c8f97f8b201568cac4850164d9343d056cbb5190999fc90e7e3dde4541db
Endorser 0 endorser: mspid Org2MSP 
 certificate -----BEGIN CERTIFICATE-----
MIICGDCCAb+gAwIBAgIQKHCjvLJSTkKm5lsAG4StsTAKBggqhkjOPQQDAjBzMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEZMBcGA1UEChMQb3JnMi5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu
b3JnMi5leGFtcGxlLmNvbTAeFw0xODAyMjUxMjQzMjlaFw0yODAyMjMxMjQzMjla
MFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T
YW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMS5vcmcyLmV4YW1wbGUuY29tMFkw
EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIPHSGaXYokkyDT7hjv7xR7qdr/4unay4
6ney+f+SaX3/+GS23ETzxjeZYyoKYy+nMjTGVtMx1k9m/KHHZUS4PaNNMEswDgYD
VR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgeyt2U8RRLWzp
U144FAY19Tm9ihML5UrJT34TG3Wg8j4wCgYIKoZIzj0EAwIDRwAwRAIgRiUmbSDL
ZT4ETQzsS57MpfinlBo+WM/3ChUtTOL8BlgCIB8jfwjtaP22vH4w+V52ztTgQCnq
lCO/1jpx9z0ii78C
-----END CERTIFICATE-----

Endorser 1 signature: 30440220638d547f6470c48a40bd4e25c3818339a535102e5b40eb0b08be8184625f142602204b4e4f33d269b2473dc41ca681018d8b0ffeabb50ec4b4c0cee7fe40976a9784
Endorser 1 endorser: mspid Org2MSP 
 certificate -----BEGIN CERTIFICATE-----
MIICGTCCAcCgAwIBAgIRAKoFq36AGyh9tmw1qzjKp2YwCgYIKoZIzj0EAwIwczEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzIuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzIuZXhhbXBsZS5jb20wHhcNMTgwMjI1MTI0MzI5WhcNMjgwMjIzMTI0MzI5
WjBbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN
U2FuIEZyYW5jaXNjbzEfMB0GA1UEAxMWcGVlcjAub3JnMi5leGFtcGxlLmNvbTBZ
MBMGByqGSM49AgEGCCqGSM49AwEHA0IABFBM3gDUs/4Mp9DyF/uiUQkQk1UvqmmC
uhuAXJgeTAob/tzvsLGGRS78dsuPVSGVS3p4vtuPhUBMVKtrnscgjemjTTBLMA4G
A1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIHsrdlPEUS1s
6VNeOBQGNfU5vYoTC+VKyU9+Ext1oPI+MAoGCCqGSM49BAMCA0cAMEQCIDbFc/hr
0RYfp0e9HqBW+tel9c9VCW7E+C7XO4e7ZYBJAiAVkjEFKpKadLUpA2cK0YHobNRH
zxIaKjL+wLVfr2wTzQ==
-----END CERTIFICATE-----

   Transaction action 1 has 4 chaincode input arguments
     Transaction action 1 has chaincode input argument 0 is: move
     Transaction action 1 has chaincode input argument 1 is: a
     Transaction action 1 has chaincode input argument 2 is: b
     Transaction action 1 has chaincode input argument 3 is: 100
   Transaction action 1 proposal response status: 222
   Transaction action 1 proposal response payload: :)
   Transaction action 1 proposal chaincodeIDName: example_cc_go, chaincodeIDVersion: 1,  chaincodeIDPath: github.com/example_cc 
   Transaction action 1 has 2 name space read write sets
     Namespace example_cc_go read set 0 key a  version [1:0]
     Namespace example_cc_go read set 1 key b  version [1:0]
     Namespace example_cc_go write set 0 key a has value '400' 
     Namespace example_cc_go write set 1 key b has value '400' 
     Namespace lscc read set 0 key example_cc_go  version [1:0]
current block number 1 has data hash: 3a8537830cd87e9ab6dc08e714f7d206b623cb42eefde158e7b65cd4532342d9
current block number 1 has previous hash id: 592833913b4a5aca4ad72ced1fad3e2e5676543bd439b68b4a2ba5c733cba6cb
current block number 1 has calculated block hash is 0f201de1747c6423e824b929687b77c87f2a526389bd3cccb8acd497206e19bc
current block number 1 has 1 envelope count:
  Transaction number 1 has transaction id: 552d9263a9c27b7773d4d6b2576e492cb9ca2b2cb5867b6f7a8faa91a0f95455
  Transaction number 1 has channel id: bar
  Transaction number 1 has epoch: 0
  Transaction number 1 has transaction timestamp: 一月 22,  2019  09:52:44 上午
  Transaction number 1 has type id: TRANSACTION_ENVELOPE
  Transaction number 1 has nonce : 3c405cd6a29f0df03497fdb29de29d572d29617d4ffeac1e
  Transaction number 1 has submitter mspid: Org2MSP,  certificate: -----BEGIN CERTIFICATE-----
MIICGjCCAcCgAwIBAgIRAIrZokP5xguxCqWjUeu0jnAwCgYIKoZIzj0EAwIwczEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzIuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzIuZXhhbXBsZS5jb20wHhcNMTgwMjI1MTI0MzI5WhcNMjgwMjIzMTI0MzI5
WjBbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN
U2FuIEZyYW5jaXNjbzEfMB0GA1UEAwwWQWRtaW5Ab3JnMi5leGFtcGxlLmNvbTBZ
MBMGByqGSM49AgEGCCqGSM49AwEHA0IABGDqXVD4yOX65oU0eY3j5UtD8Gr8n/s+
eODjPP76wNeBoSqljQYM+D953dBtzZ87udrwQ2uvcpUI1R1mHTMuNmSjTTBLMA4G
A1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIHsrdlPEUS1s
6VNeOBQGNfU5vYoTC+VKyU9+Ext1oPI+MAoGCCqGSM49BAMCA0gAMEUCIQCojuxd
EqSDDDUUJstAmAqU65xkd1/Yf0BVpLdCe++WigIgLWC9rBPpUa+Yhe3yy00+BlqG
xZ0h2eeiHaMuF6Qawy4=
-----END CERTIFICATE-----

  Transaction number 1 has 1 actions
  Transaction number 1 isValid true
  Transaction number 1 validation code 0
   Transaction action 1 has response status 200
   Transaction action 1 has response message bytes as string: 
   Transaction action 1 has 2 endorsements
Endorser 0 signature: 304402207c6f02978bc0d15261b5ba09eb400ad9a0aadd5363a9f8e48d149599fc1a08c802205dfaf91652ef4b400cbe568a14a35a635f8945e43e4d2e8095956819f7e3d2c0
Endorser 0 endorser: mspid Org2MSP 
 certificate -----BEGIN CERTIFICATE-----
MIICGDCCAb+gAwIBAgIQKHCjvLJSTkKm5lsAG4StsTAKBggqhkjOPQQDAjBzMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEZMBcGA1UEChMQb3JnMi5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu
b3JnMi5leGFtcGxlLmNvbTAeFw0xODAyMjUxMjQzMjlaFw0yODAyMjMxMjQzMjla
MFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T
YW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMS5vcmcyLmV4YW1wbGUuY29tMFkw
EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIPHSGaXYokkyDT7hjv7xR7qdr/4unay4
6ney+f+SaX3/+GS23ETzxjeZYyoKYy+nMjTGVtMx1k9m/KHHZUS4PaNNMEswDgYD
VR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgeyt2U8RRLWzp
U144FAY19Tm9ihML5UrJT34TG3Wg8j4wCgYIKoZIzj0EAwIDRwAwRAIgRiUmbSDL
ZT4ETQzsS57MpfinlBo+WM/3ChUtTOL8BlgCIB8jfwjtaP22vH4w+V52ztTgQCnq
lCO/1jpx9z0ii78C
-----END CERTIFICATE-----

Endorser 1 signature: 3045022100ec453db839140182b5450cf0a35f6174e264a3dbf4800cb73be9f5cca2026bf3022036b490d5d5bd46e55ba7fe4a917e5622a712752a66f9fdb87426f9531ca2f690
Endorser 1 endorser: mspid Org2MSP 
 certificate -----BEGIN CERTIFICATE-----
MIICGTCCAcCgAwIBAgIRAKoFq36AGyh9tmw1qzjKp2YwCgYIKoZIzj0EAwIwczEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzIuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzIuZXhhbXBsZS5jb20wHhcNMTgwMjI1MTI0MzI5WhcNMjgwMjIzMTI0MzI5
WjBbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN
U2FuIEZyYW5jaXNjbzEfMB0GA1UEAxMWcGVlcjAub3JnMi5leGFtcGxlLmNvbTBZ
MBMGByqGSM49AgEGCCqGSM49AwEHA0IABFBM3gDUs/4Mp9DyF/uiUQkQk1UvqmmC
uhuAXJgeTAob/tzvsLGGRS78dsuPVSGVS3p4vtuPhUBMVKtrnscgjemjTTBLMA4G
A1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIHsrdlPEUS1s
6VNeOBQGNfU5vYoTC+VKyU9+Ext1oPI+MAoGCCqGSM49BAMCA0cAMEQCIDbFc/hr
0RYfp0e9HqBW+tel9c9VCW7E+C7XO4e7ZYBJAiAVkjEFKpKadLUpA2cK0YHobNRH
zxIaKjL+wLVfr2wTzQ==
-----END CERTIFICATE-----

   Transaction action 1 has 4 chaincode input arguments
     Transaction action 1 has chaincode input argument 0 is: deploy
     Transaction action 1 has chaincode input argument 1 is: bar
     Transaction action 1 has chaincode input argument 2 is: ?E???)??github.com/example_cc??example_cc_go??1????init??a??500?...
     Transaction action 1 has chaincode input argument 3 is: ? ??????????????????????????????????????Org1MSP??????Org2MSP????...
   Transaction action 1 proposal response status: 200
   Transaction action 1 proposal response payload: ??example_cc_go??1??escc"?vscc*Z? ??????????????????????????????...
   Transaction action 1 proposal chaincodeIDName: lscc, chaincodeIDVersion: 1.4.0,  chaincodeIDPath:  
   Transaction action 1 has 2 name space read write sets
     Namespace example_cc_go write set 0 key a has value '500' 
     Namespace example_cc_go write set 1 key b has value '300' 
     Namespace lscc read set 0 key example_cc_go  version [0:0]
     Namespace lscc write set 0 key example_cc_go has value '??example_cc_go??1??escc"?vscc*Z? ??????????????????????????????...' 
current block number 0 has data hash: df4a7033e59c3a527ae05082972a928e215e06f1d2f62d21fb1ea10418621ae0
current block number 0 has previous hash id: 
current block number 0 has calculated block hash is 592833913b4a5aca4ad72ced1fad3e2e5676543bd439b68b4a2ba5c733cba6cb
current block number 0 has 1 envelope count:
  Transaction number 1 has transaction id: 
  Transaction number 1 has channel id: bar
  Transaction number 1 has epoch: 0
  Transaction number 1 has transaction timestamp: 一月 22,  2019  09:52:42 上午
  Transaction number 1 has type id: ENVELOPE
  Transaction number 1 has nonce : d23d406599aaec1d88ef0ebd311fd6d68c32d158ecd6fcaf
  Transaction number 1 has submitter mspid: OrdererMSP,  certificate: -----BEGIN CERTIFICATE-----
MIICCzCCAbKgAwIBAgIQUcfZvWT8UgJJ30cDzW15bDAKBggqhkjOPQQDAjBpMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w
bGUuY29tMB4XDTE4MDIyNTEyNDMyOVoXDTI4MDIyMzEyNDMyOVowWDELMAkGA1UE
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
Y28xHDAaBgNVBAMTE29yZGVyZXIuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggq
hkjOPQMBBwNCAARQfP/qUmnEcXIlE5PlkR4RCMn2XykMsPFZN0k1XfpkSA4KP0nC
ALUgiITKLsOQohYA7oDaFQD/ZhaRswgwEgmNo00wSzAOBgNVHQ8BAf8EBAMCB4Aw
DAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCAZtRU3kIVNroUKD5QVcPw8VpuHhyOT
OtWpwxnSk/LUkjAKBggqhkjOPQQDAgNHADBEAiApAQ0e/qdVsd5qtXGHqYKRt30Y
LPaGPmy8wbX8+/KDhwIgXtt1TL97Z0rfq7iKXzXLRNk8jNntsrmRFoLVstXr3dA=
-----END CERTIFICATE-----

That's all folks!

3、源码分析

3.1、检查配置文件

checkConfig方法,构造测试组织的fabric-ca-client(用于和fabric网络交互的入口)。能够让客户端使用rest风格调用,这样能够注册用户和添加用户

3.2、注册用户并加入

enrollUsersSetup方法将会注册用户并加入组织。该方法为组织org1注册user、admin以及peer(peer用户能够创建channel、加入peer节点、安装chaincode)。

3.3、创建通道

关键代码分析

 //调用
 Channel fooChannel = constructChannel(FOO_CHANNEL_NAME, client, sampleOrg);
 //定义
  Channel constructChannel(String name, HFClient client, SampleOrg sampleOrg) throws Exception {
	 //只有peer用户能够创建channel
	 SampleUser peerAdmin = sampleOrg.getPeerAdmin();
	 client.setUserContext(peerAdmin);
	 ...
	 //官方工具查看tx文件内容 https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/configtxgen.html?highlight=.tx
	 //路径位于fabric-sdk-java-master\src\test\fixture\sdkintegration\e2e-2Orgs\v1.3
	 String path = TEST_FIXTURES_PATH + "/sdkintegration/e2e-2Orgs/" + testConfig.getFabricConfigGenVers() + "/" + name + ".tx";
	 //将channel加入peer、orderer,绑定时间监听
}

3.4、安装链码并实例化

关键代码分析

 //调用
runChannel(client, fooChannel, true, sampleOrg, 0);
 //定义
void runChannel(HFClient client, Channel channel, boolean installChaincode, SampleOrg sampleOrg, int delta) {
	//安装链码
	Collection<Peer> peers = channel.getPeers();
    responses = client.sendInstallProposal(installProposalRequest, peers);
    for (ProposalResponse response : responses) {
       //查看安装链码的结果            
    }
    //实例化链码
    responses = channel.sendInstantiationProposal(instantiateProposalRequest, channel.getPeers());
    for (ProposalResponse response : responses) {
       //查看实例化链码的结果            
    }
    //a向b转账100的操作
    TransactionProposalRequest transactionProposalRequest = client.newTransactionProposalRequest();
    transactionProposalRequest.setChaincodeID(chaincodeID);
    transactionProposalRequest.setChaincodeLanguage(CHAIN_CODE_LANG);
    transactionProposalRequest.setFcn("move");
    transactionProposalRequest.setProposalWaitTime(testConfig.getProposalWaitTime());
    transactionProposalRequest.setArgs("a", "b", "100");
    Collection<ProposalResponse> transactionPropResp = channel.sendTransactionProposal(transactionProposalRequest, channel.getPeers());
    for (ProposalResponse response : transactionPropResp ) {
       //查看转账操作的结果            
    }
    //验证交易一致性
     Collection<Set<ProposalResponse>> proposalConsistencySets = SDKUtils.getProposalConsistencySets(transactionPropResp);
     // 交易信息发送给orderer
     channel.sendTransaction(successful).get(testConfig.getTransactionWaitTime(), TimeUnit.SECONDS);
     // 查询b的值
     QueryByChaincodeRequest queryByChaincodeRequest = client.newQueryProposalRequest();
     queryByChaincodeRequest.setArgs(new String[] {"b"});
     queryByChaincodeRequest.setFcn("query");
     queryByChaincodeRequest.setChaincodeID(chaincodeID);
     // 查询channel中区块链高度等信息
}

备注

查看源码和fabric理论有如下几个不一致的地方:
1、实例化链码只需实例化一次,但代码中在所有peer都实例化。

responses = channel.sendInstantiationProposal(instantiateProposalRequest, channel.getPeers());

2、客户端提交交易请求,向需要背书的peer发送请求,获得背书后再发送请求至orderer,orderer再广播至其他peer存储此次交易。
a:代码是向所有peer发送背书请求。修改代码后尝试也是可以的,和背书策略相关。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐