如何在链码内部获得块哈希超级织物
目前,我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可能从链码内获得。我不确定无论如何您都会想到,因为不同的同行可能处于不同的高度,并且您会获得不同的认可结果,从而导致交易无效。
我建议将客户端查询此信息并将其传递到调用的链码中作为输入。
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.