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 https://chainhero.io/2017/07/tutorial-build-blockchain-app/

Fabric Basic App using GoLang SDK - Code https://github.com/chainHero/heroes-service/

GoLang SDK - Official SDK https://github.com/hyperledger/fabric-sdk-go

  • 写回答

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"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格