通过 TxId 或哈希搜索块

Dar*_* Bc 1 blockchain hyperledger hyperledger-fabric

对于任何平台,是否有任何用例或流程,其中通过区块链中的哈希或交易 ID 搜索块?

Rod*_*eal 5

LSCC 向用户公开了某些功能,以便可以查询存储在块存储上的块和事务。它提供以下五个函数:(i) GetChainInfo, (ii) GetBlockByNumber, (iii) GetBlockByHash, (iv) GetTransactionByID, 和 (v) GetBlockByTxID

GetBlockByNumber 功能用于获取序列化块。以下命令从通道 ch1 检索块编号 3。

$ peer chaincode query -C "" -n qscc -c '{"Args":["GetBlockByNumber", "ch1", "3"]}'
Run Code Online (Sandbox Code Playgroud)

通过 txId 获取块将类似于。

$ peer chaincode query -C "" -n qscc -c '{"Args":["GetBlockByTxID", "ch1", "txId"]}'
Run Code Online (Sandbox Code Playgroud)

您可以使用 Fabric CLI 运行此命令。

更多信息在这里