hyperledger-fabric - Hyperledger Fabric 1.0 如何通过名称获取 channel

标签 hyperledger-fabric

从 java SDK 创建 channel

Channel newChannel = hfclient.
                 newChannel("foo", anOrderer, channelConfiguration, channelConfig);

在docker容器中日志 channel 创建成功

问题:

  1. 无法创建同名 channel - 收到 400 BAD REQUEST channel 存在吗?
  2. 我无法按名称获取 channel hfclient.getChannel("") = null
  3. 如何创建 channel ?
  4. 如何检查 docker 容器中的现有 channel 列表?

最佳答案

您可以通过调用 CSCC 查询可用 channel (配置系统链码),提供以下API:

// These are function names from Invoke first parameter
const (
    JoinChain      string = "JoinChain"
    GetConfigBlock string = "GetConfigBlock"
    GetChannels    string = "GetChannels"
)

执行此操作的 Java SDK 代码如下所示:

    final Channel channel = client.newChannel("");

    channel.addOrderer(client.newOrderer("orderer0", "grpc://localhost:7050"));
    channel.addPeer(client.newPeer("peer0", "grpc://localhost:7051"));

    channel.initialize();

    final TransactionProposalRequest proposalRequest = client.
                                                   newTransactionProposalRequest();

    final ChaincodeID chaincodeID = ChaincodeID.newBuilder()
            .setName("cscc")
            .setPath("github.com/C0rWin/pgdays/chaincode/personsV3")
            .build();

    proposalRequest.setChaincodeID(chaincodeID);
    proposalRequest.setFcn("GetChannels");
    proposalRequest.setProposalWaitTime(TimeUnit.SECONDS.toMillis(10));

    final Collection<ProposalResponse> responses = channel.
                                          sendTransactionProposal(proposalRequest);

关于hyperledger-fabric - Hyperledger Fabric 1.0 如何通过名称获取 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45573727/

相关文章:

blockchain - node.js 中的 transientMap 和链码中的 getTransient

hyperledger-fabric - ssl_transport_security.cc :599] Could not load any root certificate

hyperledger-fabric - Hyperledger Fabric 上的身份管理

hyperledger-fabric - 结构重启之间的 Hyperledger 数据持久性

docker - 证书是如何从 super 账本中 hfc-key-store 中真实的 fabric-ca-server 证书派生出来的?

hyperledger-fabric - 错误 : No MSP found able to do that while adding a new org to a network

docker - 在composer中将主机名更改为docker可解析的主机名

node.js - 使用 Node.js SDK 调用链代码时出错 [TypeError : Cannot read property 'getConnectivityState' of undefined]

hyperledger - Hyperledger Fabric 共识服务可以分发吗?

kubernetes - 在Kubernetes中正确配置Fabric Peers