如何在链码内部获得块哈希超级织物

发布于 2025-02-10 08:00:07 字数 637 浏览 1 评论 0原文

目前,我正在使用Hyperledger Fabric Chaincode,并尝试获得最后一个块的哈希,但我还没有找到任何方法来获得它。我需要我的链代码来访问此哈希以进行安全检查。

我试图从链表中调用QSCC,从客户端确实返回区块链和哈希块信息,但是以这种方式访问​​受到限制。

代码

   @Transaction()
   public String getBlockHash(final Context ctx) {
       ChaincodeStub stub = ctx.getStub();
       String[] argsQscc = {"GetChainInfo","mychannel"};
       Response response = stub.invokeChaincodeWithStringArgs("qscc", argsQscc);
       System.out.println("Result"+response.getMessage());
       return response.getMessage();
   }

错误 由于潜在的僵局,拒绝QSCC从另一个链代码中拒绝QSCC的调用,因此请调用“ MyChainCode”。

Currently I'm working with Hyperledger Fabric chaincode and trying to get the hash of last block but I haven't found any way to get it. I need my chaincode to access this hash to do a security check.

I have tried to invoke qscc from my chaincode, which from a client does return blockchain and hash block information, but in this way access is restricted.

Code

   @Transaction()
   public String getBlockHash(final Context ctx) {
       ChaincodeStub stub = ctx.getStub();
       String[] argsQscc = {"GetChainInfo","mychannel"};
       Response response = stub.invokeChaincodeWithStringArgs("qscc", argsQscc);
       System.out.println("Result"+response.getMessage());
       return response.getMessage();
   }

Error
Rejecting invoke of QSCC from another chaincode because of potential for deadlocks, original invocation for 'mychaincode'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸里的快感 2025-02-17 08:00:07

不可能从链码内获得。我不确定无论如何您都会想到,因为不同的同行可能处于不同的高度,并且您会获得不同的认可结果,从而导致交易无效。

我建议将客户端查询此信息并将其传递到调用的链码中作为输入。

It is not possible to get from within chaincode. I'm not sure you would want to anyways, because different peers may be at different heights and you would get different endorsement results leading to an invalidation of your transaction.

I'd suggest to have client query this information and pass it into the invoked chaincode as an input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文