自从上篇Java-sdk跑通之后,今天已经是8/17号了,这期间干嘛了呢?一直在尝试搭建出一个Java应用层,好对外提供简单的接口以便将来能够实现一些自己的存储。
此篇博客记录时,CA容器没有单独起,而仅仅是在客户端读取已经生成好的CA文件来成功访问。下面说下一些步骤。
1. 搭建出一个Fabric环境。
搭建过程
1.1 这边需要注意1.3 用工具生成的私钥和证书,我们需要拷贝到工程中去。
channel-artifacts 和 crypto-config(这一个是这一期主要的)
2. 整个工程目录如图,只是一个简单的java项目
3. pom文件如下:
4.0.0
com.tc.fabric
FabricSdk
1.0-SNAPSHOT
junit
junit
4.12
log4j
log4j
1.2.14
org.hyperledger.fabric-sdk-java
fabric-sdk-java
1.0.0
org.apache.maven.plugins
maven-compiler-plugin
3.1
1.8
1.8
4. CommonUtils
package com.t.fabric;
public class CommonUtils {
//peer节点的CA文件路径
public static final String cryptoPeerPath = "crypto-config/peerOrganizations/";
//order节点的CA文件路径
public static final String cryptoOrderPath = "crypto-config/ordererOrganizations/";
//peer节点的CA文件路径
public static String peerFilePath = CommonUtils.class.getResource("/").getPath() + cryptoPeerPath;
//order节点的CA文件路径
public static String orderFilePath = CommonUtils.class.getResource("/").getPath() + cryptoOrderPath;
//org1组织的目录
public static final String org1Path = "org1.example.com/users/";
//org1组织的cert文件目录
public static final String org1CertFilePath = "@org1.example.com/msp/signcerts/";
//org1组织的Key文件目录
public static final String org1KeyFilePath = "@org1.example.com/msp/keystore/";
//org2组织的目录
public static final String org2Path = "org2.example.com/users/";
//org2组织的cert文件目录
public static final String org2CertFilePath = "@org2.example.com/msp/signcerts/";
//org2组织的Key文件目录
public static final String org2KeyFilePath = "@org2.example.com/msp/keystore/";
//链码名称
public static final String chainCodeName = "mycc";
//链码版本
public static final String chaincodeVersion = "1";
//channel名称
public static final String channelId = "mychannel";
//order名称 和 Fabrci-java-sdk保持一致
public static final String orderName = "orderer.example.com";
//peer0org1名称 和 Fabrci-java-sdk保持一致
public static final String peer0Org1Name = "peer0.org1.example.com";
//peer1org1名称 和 Fabrci-java-sdk保持一致
public static final String peer1Org1Name = "peer1.org1.example.com";
//peer0org2名称 和 Fabrci-java-sdk保持一致
public static final String peer0Org2Name = "peer0.org2.example.com";
//peer1org2名称 和 Fabrci-java-sdk保持一致
public static final String peer1Org2Name = "peer1.org2.example.com";
//order地址
public static final String orderLocation = "grpc://localhost:7050";
//peer0org1地址
public static final String peer0Org1Location = "grpc://localhost:7051";
//peer1org1地址
public static final String peer1Org1Location = "grpc://localhost:8051";
//peer0org2地址
public static final String peer0Org2Location = "grpc://localhost:9051";
//peer1org2地址
public static final String peer1Org2Location = "grpc://localhost:10051";
}
5.FabricUtils
package com.t.fabric;
import org.apache.log4j.Logger;
import org.hyperledger.fabric.sdk.*;
import org.hyperledger.fabric.sdk.security.CryptoSuite;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* FabricUtils,暂时不关注CA方面的东西
*/
public class FabricUtils {
//日志记录
private static Logger logger = Logger.getLogger(FabricUtils.class);
//CA客户端
public static HFClient client = null;
public static CryptoSuite cs = null;
public static HashMap orgHashMap=null;
public static ChaincodeID cid = null;
public static User peer0org1=null;
public static void init()throws Exception{
cs = CryptoSuite.Factory.getCryptoSuite();
cid = ChaincodeID.newBuilder().setName(CommonUtils.chainCodeName).build();
client = HFClient.createNewInstance();
client.setCryptoSuite(cs);
orgHashMap = OrgConfig.getSOrg();
peer0org1 = orgHashMap.get("org1").getAdmin();
client.setUserContext(peer0org1);
}
/*
* 实现插入数据
* */
public static void instertFabcar(Channel channel, DataRecord data) throws Exception {
TransactionProposalRequest req = client.newTransactionProposalRequest();
req.setChaincodeID(cid);
req.setFcn("set");
req.setArgs(data.toStringArray());
Map tm2 = new HashMap<>();
//代码来自End2End
tm2.put("HyperLedgerFabric", "TransactionProposalRequest:JavaSDK".getBytes(UTF_8));
tm2.put("method", "TransactionProposalRequest".getBytes(UTF_8));
tm2.put("result", ":)".getBytes(UTF_8));
req.setTransientMap(tm2);
Collection resps = channel.sendTransactionProposal(req);
for (ProposalResponse resp : resps) {
String payload = new String(resp.getChaincodeActionResponsePayload());
logger.debug("payload!!!!!!!: "+payload);
}
channel.sendTransaction(resps);
}
/*
* 实现给定的Key查询数据
* */
public static void queryFabcar(Channel channel, String key) throws Exception {
QueryByChaincodeRequest req = client.newQueryProposalRequest();
ChaincodeID cid = ChaincodeID.newBuilder().setName(CommonUtils.chainCodeName).build();
req.setChaincodeID(cid);
req.setFcn("get");
req.setArgs(new String[] { key });
Collection resps = channel.queryByChaincode(req);
for (ProposalResponse resp : resps) {
String payload = new String(resp.getChaincodeActionResponsePayload());
logger.debug("payload!!!!!!!: "+payload);
}
}
}
6. OrgConfig
package com.t.fabric;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.hyperledger.fabric.sdk.Enrollment;
import java.io.*;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.util.HashMap;
/**
* 模拟peer,order,admin,user等一些配置项
*/
public class OrgConfig {
/**
* 获取Org组织信息,
* 代码精简自End2End
* @return
*/
public static HashMap getSOrg() throws Exception{
HashMap orgMap = new HashMap<>();
SOrg org1=new SOrg("Org1","Org1MSP");
org1.addPeerLocation(CommonUtils.peer0Org1Name,CommonUtils.peer0Org1Location);
org1.addPeerLocation(CommonUtils.peer1Org1Name,CommonUtils.peer1Org1Location);
org1.addOrdererLocation(CommonUtils.orderName,CommonUtils.orderLocation);
SUser adminOrg1 = new SUser("Admin","Org1MSP");
SUser user1Org1 = new SUser("User1","Org1MSP");
adminOrg1.setEnrollment(new SampleStoreEnrollement(getKeyFile(adminOrg1.getName(),adminOrg1.getMspId())
,getCertificateFile(adminOrg1.getName(),adminOrg1.getMspId())));
user1Org1.setEnrollment(new SampleStoreEnrollement(getKeyFile(user1Org1.getName(),user1Org1.getMspId())
,getCertificateFile(user1Org1.getName(),user1Org1.getMspId())));
org1.addUser(adminOrg1);
org1.addUser(user1Org1);
org1.setAdmin(adminOrg1);
SOrg org2=new SOrg("Org2","Org2MSP");
org2.addPeerLocation(CommonUtils.peer0Org2Name,CommonUtils.peer0Org2Location);
org2.addPeerLocation(CommonUtils.peer1Org2Name,CommonUtils.peer1Org2Location);
org2.addOrdererLocation(CommonUtils.orderName,CommonUtils.orderLocation);
SUser adminOrg2 = new SUser("Admin","Org2MSP");
SUser user1Org2 = new SUser("User1","Org2MSP");
adminOrg2.setEnrollment(new SampleStoreEnrollement(getKeyFile(adminOrg2.getName(),adminOrg2.getMspId())
,getCertificateFile(adminOrg2.getName(),adminOrg2.getMspId())));
user1Org2.setEnrollment(new SampleStoreEnrollement(getKeyFile(user1Org2.getName(),user1Org2.getMspId())
,getCertificateFile(user1Org2.getName(),user1Org2.getMspId())));
org2.addUser(adminOrg2);
org2.addUser(user1Org2);
org2.setAdmin(adminOrg2);
orgMap.put("org1",org1);
orgMap.put("org2",org2);
return orgMap;
}
/**
* 获取对应用户的私钥Key
* @param userName
* @param mspId
* @return
*/
public static PrivateKey getKeyFile(String userName,String mspId) throws Exception{
String tempPath = null;
String fileName = null;
String keyFile = null;
if("Org1MSP".equals(mspId)){
tempPath = CommonUtils.peerFilePath +CommonUtils.org1Path + userName + CommonUtils.org1KeyFilePath;
fileName = new File(tempPath).listFiles()[0].getName();
keyFile = tempPath + fileName;
}else {
tempPath = CommonUtils.peerFilePath + CommonUtils.org2Path + userName + CommonUtils.org2KeyFilePath;
fileName = new File(tempPath).listFiles()[0].getName();
keyFile = tempPath + fileName;
}
//来源于ChannelTest
return getPrivateKeyFromBytes(IOUtils.toByteArray(new FileInputStream(keyFile)));
}
/**
* 获取对应用户的ceritificate证书
* @param userName
* @param mspId
* @return
* @throws Exception
*/
public static String getCertificateFile(String userName,String mspId) throws Exception{
String tempPath = null;
String fileName = null;
String certFile = null;
if("Org1MSP".equals(mspId)){
tempPath = CommonUtils.peerFilePath + CommonUtils.org1Path + userName + CommonUtils.org1CertFilePath;
fileName = new File(tempPath).listFiles()[0].getName();
certFile = tempPath + fileName;
}else {
tempPath = CommonUtils.peerFilePath + CommonUtils.org2Path + userName + CommonUtils.org2CertFilePath;
fileName = new File(tempPath).listFiles()[0].getName();
certFile = tempPath + fileName;
}
//来源于ChannelTest
return new String(IOUtils.toByteArray(new FileInputStream(certFile)), "UTF-8");
}
public static PrivateKey getPrivateKeyFromBytes(byte[] data) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException, IOException {
final Reader pemReader = new StringReader(new String(data));
final PrivateKeyInfo pemPair;
try (PEMParser pemParser = new PEMParser(pemReader)) {
pemPair = (PrivateKeyInfo) pemParser.readObject();
}
PrivateKey privateKey = new JcaPEMKeyConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getPrivateKey(pemPair);
return privateKey;
}
static final class SampleStoreEnrollement implements Enrollment, Serializable {
private final PrivateKey privateKey;
private final String certificate;
SampleStoreEnrollement(PrivateKey privateKey, String certificate) {
this.certificate = certificate;
this.privateKey = privateKey;
}
@Override
public PrivateKey getKey() {
return privateKey;
}
@Override
public String getCert() {
return certificate;
}
}
}
7. SOrg
package com.t.fabric;
import org.hyperledger.fabric.sdk.Peer;
import org.hyperledger.fabric.sdk.User;
import org.hyperledger.fabric_ca.sdk.HFCAClient;
import java.util.*;
/**
* Java-SDK直接复制得来
*/
public class SOrg {
private String name;
private String mspid;
private HFCAClient caClient; //暂时未使用
private Map userMap = new HashMap();
private Map peerLocations = new HashMap();
private Map ordererLocations = new HashMap();
private Map eventHubLocations = new HashMap(); //暂时未使用
private Set peers = new HashSet(); //暂时未使用
private SUser admin;
private String caLocation; //暂时未使用
private Properties caProperties = null; //暂时未使用
private SUser peerAdmin; //暂时未使用
private String domainName; //暂时未使用
public SOrg(String name, String mspid) {
this.name = name;
this.mspid = mspid;
}
public void setName(String name) {
this.name = name;
}
public void setMspid(String mspid) {
this.mspid = mspid;
}
public void setCaClient(HFCAClient caClient) {
this.caClient = caClient;
}
public void setUserMap(Map userMap) {
this.userMap = userMap;
}
public void setPeerLocations(Map peerLocations) {
this.peerLocations = peerLocations;
}
public void setOrdererLocations(Map ordererLocations) {
this.ordererLocations = ordererLocations;
}
public void setEventHubLocations(Map eventHubLocations) {
this.eventHubLocations = eventHubLocations;
}
public void setPeers(Set peers) {
this.peers = peers;
}
public void setAdmin(SUser admin) {
this.admin = admin;
}
public void setCaLocation(String caLocation) {
this.caLocation = caLocation;
}
public void setCaProperties(Properties caProperties) {
this.caProperties = caProperties;
}
public void setPeerAdmin(SUser peerAdmin) {
this.peerAdmin = peerAdmin;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getName() {
return name;
}
public String getMspid() {
return mspid;
}
public HFCAClient getCaClient() {
return caClient;
}
public Map getUserMap() {
return userMap;
}
public Map getPeerLocations() {
return peerLocations;
}
public Map getOrdererLocations() {
return ordererLocations;
}
public Map getEventHubLocations() {
return eventHubLocations;
}
public Set getPeers() {
return peers;
}
public SUser getAdmin() {
return admin;
}
public String getCaLocation() {
return caLocation;
}
public Properties getCaProperties() {
return caProperties;
}
public SUser getPeerAdmin() {
return peerAdmin;
}
public String getDomainName() {
return domainName;
}
public void addPeerLocation(String name, String location) {
peerLocations.put(name, location);
}
public void addOrdererLocation(String name, String location) {
ordererLocations.put(name, location);
}
public void addEventHubLocation(String name, String location) {
eventHubLocations.put(name, location);
}
public String getPeerLocation(String name) {
return peerLocations.get(name);
}
public String getOrdererLocation(String name) {
return ordererLocations.get(name);
}
public String getEventHubLocation(String name) {
return eventHubLocations.get(name);
}
public void addUser(SUser user) {
userMap.put(user.getName(), user);
}
}
8.SUser
package com.t.fabric;
import org.hyperledger.fabric.sdk.Enrollment;
import org.hyperledger.fabric.sdk.User;
import java.util.HashSet;
import java.util.Set;
/**
* SUser的构造用crypton工具生成的证书本地读取来生成
*/
public class SUser implements User {
private String userName;
private String mspid;
private Enrollment enrollment;
public SUser(String userName, String mspid) {
this.userName = userName;
this.mspid = mspid;
}
public String getName() {
return userName;
}
public Set getRoles() {
return new HashSet();
}
public String getAccount() {
return "";
}
public String getAffiliation() {
return "";
}
public Enrollment getEnrollment() {
return this.enrollment;
}
public String getMspId() {
return this.mspid;
}
public void setEnrollment(Enrollment enrollment) {
this.enrollment = enrollment;
}
}
9. DataRecord
package com.t.fabric;
public class DataRecord {
private String key;
private String value;
public DataRecord(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
public void setKey(String key) {
this.key = key;
}
public void setValue(String value) {
this.value = value;
}
public String[] toStringArray() {
return new String[] {this.getKey(),this.getValue()};
}
@Override
public String toString() {
return "Data: key = "+key+" value = " +value;
}
}
10 .Insert
package com.t.fabric;
import org.apache.log4j.Logger;
import org.hyperledger.fabric.sdk.Channel;
public class TestFabricInsert {
private static Logger logger=Logger.getLogger(TestFabricInsert.class);
public static void main(String[] args) throws Exception{
FabricUtils.init();
DataRecord dataRecord = new DataRecord("data","{name:\"testName\",address:\"testAddress\"}");
testInsert(dataRecord);
}
public static void testInsert(DataRecord record) throws Exception {
System.out.println("test insert");
Channel channel = FabricUtils.client.newChannel(CommonUtils.channelId);
channel.addPeer(FabricUtils.client.newPeer(CommonUtils.peer0Org1Name, CommonUtils.peer0Org1Location));
channel.addOrderer(FabricUtils.client.newOrderer(CommonUtils.orderName, CommonUtils.orderLocation));
channel.initialize();
FabricUtils.instert(channel,record);
}
}
11 .query
package com.t.fabric;
import org.apache.log4j.Logger;
import org.hyperledger.fabric.sdk.Channel;
public class TestFabricQuery {
private static Logger logger=Logger.getLogger(TestFabricQuery.class);
public static void main(String[] args) throws Exception{
DataRecord dataRecord = new DataRecord("data","");
FabricUtils.init();
testQuery(dataRecord);
}
public static void testQuery(DataRecord record) throws Exception {
logger.debug("测试Fabric 查询功能");
Channel channel = FabricUtils.client.newChannel(CommonUtils.channelId);
channel.addPeer(FabricUtils.client.newPeer(CommonUtils.peer0Org1Name, FabricUtils.orgHashMap.get("org1").getPeerLocation(CommonUtils.peer0Org1Name)));
channel.addOrderer(FabricUtils.client.newOrderer(CommonUtils.orderName, FabricUtils.orgHashMap.get("org1").getOrdererLocation(CommonUtils.orderName)));
channel.initialize();
FabricUtils.query(channel, record.getKey());
}
}
以上就是全部的精简代码了。但是如果直接运行以上代码的话会有一些环境方面的问题,我这边遇到的就是tls问题....
下面是我打开orderer的日志时发现的问题(表明不是一个合法的tls访问,个人推测):
1.错误1
grpc: Server.Serve failed to complete security handshake from "172.18.0.1:41678": tls: first record does not look like a TLS handshake
2. 伴随错误1出现在java日志里的是错误2:
Caused by: io.netty.handler.codec.http2.Http2Exception: First received frame was not SETTINGS. Hex dump for first 5 bytes: 1503010002
暂时解决方案就是关闭tls.....
1. 在e2e/base内的两个文件里面分别关掉
docker-compose-base.yaml ---- > ORDERER_GENERAL_TLS_ENABLED=false
peer-base.yaml ---- > CORE_PEER_TLS_ENABLED=false
2.在e2e/docker-compose-cli.yaml内的文件中关掉 CORE_PEER_TLS_ENABLED=false
然后重新部署环境。
需要额外注意的是,搭建步骤内的4.2 / 5.2 等涉及到tls的参数设置 --tls true 去掉。
insert输出日志:
DEBUG sdk.Channel - Creating channel: mychannel, client context Admin
DEBUG sdk.Channel - Channel mychannel adding ordererorderer.example.com, url: grpc://localhost:7050
DEBUG sdk.Channel - Channel mychannel initialize shutdown false
DEBUG sdk.Channel - getConfigurationBlock for channel mychannel
DEBUG sdk.Channel - getConfigurationBlock for channel mychannel
...
DEBUG sdk.OrdererClient - resp status value: 0, resp: UNKNOWN, type case: BLOCK
DEBUG sdk.OrdererClient - resp status value: 200, resp: SUCCESS, type case: STATUS
DEBUG sdk.Channel - Channel mychannel getLatestBlock returned status 200
DEBUG sdk.Channel - Last config index is 2
DEBUG transaction.ProtoUtils - ChannelHeader: type: DELIVER_SEEK_INFO, version: 1, Txid: 4104f7b6af57f3a9176ed9e6ce5a506304ef9d35f92d675eb8d64335ce43236d, channelId: mychannel, epoch 0
...
....
DEBUG sdk.Channel - Channel mychannel getConfigurationBlock returned
DEBUG sdk.Channel - Channel mychannel Got config block getting MSP data and anchorPeers data
DEBUG sdk.Channel - Channel mychannel loadCACertificates
DEBUG sdk.Channel - loading certificates for MSP : Org2MSP
DEBUG sdk.Channel - loading certificates for MSP : Org1MSP
DEBUG sdk.Channel - loading certificates for MSP : OrdererMSP
DEBUG sdk.Channel - Channel mychannel loadCACertificates completed
DEBUG sdk.Channel - Eventque started null
DEBUG sdk.Channel - 0 eventhubs initialized
DEBUG sdk.Channel - Channel mychannel registerTransactionListenerProcessor starting
DEBUG sdk.Channel - Channel mychannel blockListener 32a8ef34-46b6-4d3e-af61-903c2e1f27ba starting
DEBUG sdk.Channel - Channel mychannel registerTransactionListenerProcessor completed
DEBUG sdk.Channel - Channel mychannel initialized
DEBUG transaction.ProposalBuilder - transientMap('result', ':)'))
DEBUG transaction.ProposalBuilder - transientMap('method', 'TransactionProposalRequest'))
DEBUG transaction.ProposalBuilder - transientMap('HyperLedgerFabric', 'TransactionProposalRequest:JavaSDK'))
DEBUG transaction.ProtoUtils - ChannelHeader: type: ENDORSER_TRANSACTION, version: 1, Txid: 7f0dc2e2ef4beca32e50d8115fd154e1347c4e8e85ccc6ea2138013e53d731f9, channelId: mychannel, epoch 0
DEBUG transaction.ProposalBuilder - ChaincodeInvocationSpec type: GOLANG, chaincode name: mycc, chaincode path: , chaincode version: args("set", "data", "{name:"testName",address:"testAddress"}")
DEBUG transaction.ProtoUtils - SignatureHeader: nonce: af86713b93d098b8ec2ef7380a2bb584c8355c393ea0d2ab, User:Admin, MSPID: Org1MSP, idBytes: 427d0ae5efdfff9a663a66df1643f9c21130fc4b3b0f668e6d5e8df4cf43a2d6
DEBUG sdk.Channel - Channel mychannel send proposal to peer peer0.org1.example.com at url grpc://localhost:7051
DEBUG sdk.Peer - peer.sendProposalAsync name: peer0.org1.example.com, url: grpc://localhost:7051
..
..
DEBUG sdk.Channel - Channel mychannel got back from peer peer0.org1.example.com status: 200, message: OK
DEBUG fabric.FabricUtils - payload!!!!!!!:
DEBUG sdk.Channel - Channel mychannel sending transaction to orderer(s) with TxID 7f0dc2e2ef4beca32e50d8115fd154e1347c4e8e85ccc6ea2138013e53d731f9
DEBUG sdk.Orderer - Order.sendTransaction name: orderer.example.com, url: grpc://localhost:7050
....
DEBUG sdk.Channel - Channel mychannel successful sent to Orderer transaction id: 7f0dc2e2ef4beca32e50d8115fd154e1347c4e8e85ccc6ea2138013e53d731f9
query输出日志:
DEBUG helper.Config - Loading configuration from /home/dell/go/javaproject/FabricSdk/config.properties and it is present: false
WARN helper.Config - Failed to load any configuration from: config.properties. Using toolkit defaults
DEBUG sdk.HFClient - Setting user context to MSPID: Org1MSP user: Admin
DEBUG fabric.TestFabricQuery - 测试Fabric 查询功能
DEBUG sdk.Channel - Creating channel: mychannel, client context Admin
DEBUG sdk.Channel - Channel mychannel adding ordererorderer.example.com, url: grpc://localhost:7050
DEBUG sdk.Channel - Channel mychannel initialize shutdown false
DEBUG sdk.Channel - getConfigurationBlock for channel mychannel
DEBUG sdk.Channel - getConfigurationBlock for channel mychannel
DEBUG transaction.ProtoUtils - ChannelHeader: type: DELIVER_SEEK_INFO, version: 1, Txid: 7341e25d471cbc614a1a996f896462286a20f9ba78fd72b619fdedfed674255f, channelId: mychannel, epoch 0
DEBUG sdk.Orderer - Order.sendDeliver name: orderer.example.com, url: grpc://localhost:7050
....
DEBUG sdk.OrdererClient - resp status value: 0, resp: UNKNOWN, type case: BLOCK
DEBUG sdk.OrdererClient - resp status value: 200, resp: SUCCESS, type case: STATUS
DEBUG sdk.Channel - Channel mychannel getLatestBlock returned status 200
..
DEBUG transaction.ProtoUtils - ChannelHeader: type: DELIVER_SEEK_INFO, version: 1, Txid: 21046ed568a93549a16224a977423351d5d7ef0ffe66455210929ab7acc6480f, channelId: mychannel, epoch 0
DEBUG sdk.Orderer - Order.sendDeliver name: orderer.example.com, url: grpc://localhost:7050
...
..
DEBUG sdk.Channel - Channel mychannel getConfigurationBlock returned
DEBUG sdk.Channel - Channel mychannel Got config block getting MSP data and anchorPeers data
DEBUG sdk.Channel - Channel mychannel loadCACertificates
DEBUG sdk.Channel - loading certificates for MSP : Org2MSP
DEBUG sdk.Channel - loading certificates for MSP : Org1MSP
DEBUG sdk.Channel - loading certificates for MSP : OrdererMSP
DEBUG sdk.Channel - Channel mychannel loadCACertificates completed
DEBUG sdk.Channel - Eventque started null
DEBUG sdk.Channel - 0 eventhubs initialized
DEBUG sdk.Channel - Channel mychannel registerTransactionListenerProcessor starting
DEBUG sdk.Channel - Channel mychannel blockListener 3d8076a4-fca7-466a-904f-5c104c96ea1f starting
DEBUG sdk.Channel - Channel mychannel registerTransactionListenerProcessor completed
DEBUG sdk.Channel - Channel mychannel initialized
DEBUG transaction.ProtoUtils - ChannelHeader: type: ENDORSER_TRANSACTION, version: 1, Txid: a08572d26702b2bdafe0ac53039e21faadb36e9a0640c9169dd66552af0a1994, channelId: mychannel, epoch 0
DEBUG transaction.ProposalBuilder - ChaincodeInvocationSpec type: GOLANG, chaincode name: mycc, chaincode path: , chaincode version: args("get", "data")
DEBUG transaction.ProtoUtils - SignatureHeader: nonce: ebc13657e548bdb8319e689baa9c263e6c8fa712835828b8, User:Admin, MSPID: Org1MSP, idBytes: 427d0ae5efdfff9a663a66df1643f9c21130fc4b3b0f668e6d5e8df4cf43a2d6
DEBUG sdk.Channel - Channel mychannel send proposal to peer peer0.org1.example.com at url grpc://localhost:7051
DEBUG sdk.Peer - peer.sendProposalAsync name: peer0.org1.example.com, url: grpc://localhost:7051
....
....
DEBUG sdk.Channel - Channel mychannel got back from peer peer0.org1.example.com status: 200, message: OK
DEBUG fabric.FabricUtils - payload!!!!!!!: {name:"testName",address:"testAddress"}
最后贴一下自己的chaincode001(其实就是以前测试的一个简单的chaincode)
chaincode