我使用devmode(https://github.com/hyperledger/fabric-samples/tree/release-1.1/chaincode-docker-devmode)设置了Hyperledger Fabric网络,并启动了链码。 我需要一种与网络通信的方式(创建/加入频道,调用链码)。
我尝试使用python-SDK(https://github.com/hyperledger/fabric-sdk-py/blob/master/docs/tutorial.md)。 初始化客户端实例需要network.json配置文件,但fabric-samples中未提供该文件,因此我尝试创建自己的文件。它没有用。
代码:
from hfc.fabric import Client
cli = Client(net_profile="network.json")
print(cli.organizations) # orgs in the network
org1_admin = cli.get_user('org1.example.com', 'Admin')
response = cli.channel_create(
'orderer',
'myc',
org1_admin,
'myc.tx')
订货人输出:
http2Server.HandleStreams收到来自客户的虚假问候
我试图为orederer使用不同的证书和名称,但它没有帮助。
network.json:
{
"name": "sample-network",
"description": "Sample network contains 4 peers (2 orgs), 1 orderer and 2 cas for Python SDK testing",
"version": "0.1",
"client": {
"organization": "Org1",
"credentialStore": {
"path": "/tmp/hfc-kvs",
"cryptoStore": {
"path": "/tmp/hfc-cvs"
},
"wallet": "wallet-name"
}
},
"organizations": {
"orderer.example.com": {
"mspid": "OrdererMSP",
"orderers": [
"orderer"
],
"certificateAuthorities": [
]
},
"org1.example.com": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com"
],
"certificateAuthorities": [
"ca-org1"
],
"users": {
"Admin": {
"cert": "msp/admincerts/admincert.pem",
"private_key": "msp/keystore/key.pem"
}
}
}
},
"orderers": {
"orderer": {
"url": "localhost:7050",
"grpcOptions": {
"ssl-target-name-override": "orderer",
"grpc-max-send-message-length": 15
},
"tlsCACerts": {
"path": "msp/cacerts/cacert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"url": "localhost:7051",
"eventUrl": "localhost:7053",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com",
"grpc.http2.keepalive_time": 15
},
"tlsCACerts": {
"path": "msp/signcerts/peer.pem"
}
}
}
}