douxian4323 2018-02-11 06:02
浏览 1791

HyperLedger Fabric获取块信息-Fabric Go SDK

I used to set up a Fabric network and deployed a fabric network and basic application using a Fabric and Fabric GoLang SDK. I'm able to do the query and write to the chain. Is there any way to retrieve the Block Info? Like block height and current hash?

+ I'm unable to find out a documentation for GoLang Fabric SDK.

I followed following code and tutorial,

Fabric Basic App - Tutorial

Fabric Basic App using GoLang SDK - Code

GoLang SDK - Official SDK

  • 写回答

3条回答 默认 最新

  • dongrui6787 2018-02-12 03:18

    In general, the sdk will provide the basic method such you said GetBlockInfo,I have search for the GoLang SDK, it can not be found. While Java sdk provide this such method reference this java test .

    Another way to use these method(you must know a little fabric source code), in fact these method are included in the system chaincode, you could invoke the system chancode just like you invoke the normal chaincode.

    A example is following: from the go sdk test ,you could see this,

    response, err := chClient.Query(chclient.Request{ChaincodeID: ccID, Fcn: "invoke", Args: integration.ExampleCCQueryArgs()})

    just change the params

    response, err := chClient.Query(chclient.Request{ChaincodeID: "qscc", Fcn: "invoke", Args: integration.ExampleCCQueryArgs("GetChainInfo")})

    qscc is a system chancode,you could download the fabric source code,and from qscc file,you could see(it provide many invoke service):

    GetChainInfo       string = "GetChainInfo"
    GetBlockByNumber   string = "GetBlockByNumber"
    GetBlockByHash     string = "GetBlockByHash"
    GetTransactionByID string = "GetTransactionByID"
    GetBlockByTxID     string = "GetBlockByTxID"
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 我下载图形界面重启完就变成这样了,打字也打不了,动也动不了,该怎么解决(操作系统-centos)
  • ¥15 VBA中在窗体中遍历所有checkbox控件,提取出被选中的checkbox的caption值
  • ¥15 在Ubuntu上有什么命令,或者是系统文件能告诉我链接nvme ssd的pcie槽位是不是支持热插拔功能?
  • ¥15 ansys license许可证问题
  • ¥20 QQ号和密码都能正常登录微信 QQ号和密码登录微信显示密码错误
  • ¥15 qiankun主应用注册子应用提示跨域
  • ¥15 单片机RTOS Kernel与应用分离开发,Kernel如何调起应用?
  • ¥15 快手小店商家版APP怎么第三方APP跳转到指定用户聊天界面
  • ¥15 为什么AVL fire软件仿真时的步长改变了,仿真结果也会改变
  • ¥100 如何帮我写一个java小游戏