如何在链码中获取Hyperledger Fabric状态的创建者?

huangapple go评论76阅读模式
英文:

How can I get the creator of a State for Hyperledger Fabric in chaincode?

问题

我想阅读一个状态的创建者的证书。我知道在调用或查询期间可以获取证书。然而,我在Fabric Go Chaincode的文档中找不到有关检索创建者证书的任何文档。

我正在寻找这样一个函数,

func GetStateCreator(key string) (key, error)  
英文:

I want to read the certificate of the creator of a state. I know that I can get the certificate during an invoke or a query. However, I could not find any documentation on Fabric Go Chaincode about retrieving the certificate of the creator.

I was looking for a function like this,

func GetStateCreator(key string) (key, error)  

答案1

得分: 1

没有一个API可以做到这一点。可能可以通过在客户端先调用链码来获取某个键的历史记录,然后再调用qscc链码来根据从历史记录中获取的事务ID检索事务(该事务创建了该键)。然后,您需要解码该响应并获取创建者证书。

可能已经有人已经找到了如何做到这一点并发布了代码示例,但没有官方的Fabric示例。

另一种选择是在您的链码实现中自行管理这个过程。

英文:

No there isn't an api to do this. It may be possible to do this client side by first invoking chaincode to get the history for a key, then you can invoke the qscc chaincode to retrieve the transaction from the id you got from the history (which created the key). You would then need to decode that response and get the creator certificate.

Someone may have already worked out how to do this and published a code example but there isn't an official fabric sample.

The alternative is that you manage this yourself within your chaincode implementation

huangapple
  • 本文由 发表于 2021年10月23日 14:11:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/69685611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定