hyperledger-fabric - How retrieve all block transactions in the Hyperledger fabric?
问题描述
As you know there is chance to have multiple transaction in one block , depend on the batch size and orderer configuration. I need to make only one call to return all transaction inside the block not one by one.
I could retrieve one transaction with queryTransaction by using fabric SDK. like
let response_payload = await channel.queryTransaction(trxnID, peer);
First Approach: implement a chanincode function and pass the block number which comes from eventHub along the method then inside the chaincode retrieve all transaction Ids and then make a query to find all transaction then stitch all together as result.
Second Approach: retrieve the block inside with fabric sdk then parse all signed proposal in the payload of the block content.
Third Approach: retrieve the block inside with fabric sdk then retrieve the transaction ids or keys in the payload and then make a couch db query to retrieve all content .
Which approach do you think is more reasonable if not what is your suggestion?
解决方案
如果您的客户端设置正确,则应该有一个
LedgerClient
它具有类似的功能
QueryBlock(blockNumber uint64, options ...ledger.RequestOption) (*common.Block, error)
获得块后,您可以从中提取数据
block, _ := QueryBlock(37)
data := block.GetData().GetData()
data
是一个[][]byte
,每个条目是一个事务。
推荐阅读
- python - Pandas:如何选择具有必须匹配的一系列值的数据框行?
- flutter - Flutter 2.5.1 - 无法为模拟器构建应用程序
- python - 如何拆分行并在行后打印输出?(Python)
- dax - 在 Power Pivot 中分组
- javascript - 未捕获的 ReferenceError:addEventListener 未定义 nodejs
- npm - npm install 时 Bcrypt (Next.js) 出错
- docker - 如何在现实生活中实际使用 Docker
- ruby-on-rails-5 - 环境错误:任务:TOP => resque:work => resque:preload => resque:setup => environment
- enterprise - 如何在 Enterprise Architect 中为对象实例类型添加新元素?
- javascript - 即使状态变量用新数据更改,反应引导表也不会呈现数据