一. pkg/client/channel channel包:通过包channel可以访问Fabric网络上的频道。 频道客户端实例提供处理程序以与指定频道上的peer交互。 频道客户端可以查询链码,执行链码以及注册/取消注册特定频道上的链码事件。 需要与多个频道交互的应用程序应为每个频道创建一个单独的频道客户端实例。

  1. 基本流程
    1. 准备频道客户端上下文
    2. 创建频道客户端
    3. 执行链码
    4. 查询链码
       1 c, err := New(mockChannelProvider("mychannel"))
       2 if err != nil {
       3     fmt.Println("failed to create client")
       4 }
       5 
       6 response, err := c.Query(Request{ChaincodeID: "testCC", Fcn: "invoke", Args: [][]byte{[]byte("query"), []byte("data")}})
       7 if err != nil {
       8     fmt.Printf("failed to query chaincode: %s\n", err)
       9 }
      10 
      11 fmt.Println(string(response.Payload))
      View Code

相关文章:

猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2021-11-03
  • 2021-07-01
相关资源
相似解决方案