gpt4 book ai didi

go - 在 Hyperledger Fabric V1.0 链代码中识别调用同级/组织

转载 作者:IT王子 更新时间:2023-10-29 02:29:07 24 4
gpt4 key购买 nike

有什么方法可以知道 golang chaincode for Hyperledger Fabric V1.0 中的调用节点和组织?

最佳答案

目前所有可用于链码的 API 都在 interface.go 中描述。文件。目前没有 API 可以让您识别链代码中的调用节点和组织。我认为这样做的主要原因是链码必须对这种类型的信息不可知,因为所有由对等方和链码管理的 ACL 都应该对其保持不可知性,无论调用它的人是谁,都应保持确定性行为,并且是无状态的。

如果需要,您可能可以尝试利用创建交易建议请求的客户的身份,方法是使用 GetCreator应用程序接口(interface):

    // GetCreator returns `SignatureHeader.Creator` (e.g. an identity)
// of the `SignedProposal`. This is the identity of the agent (or user)
// submitting the transaction.
GetCreator() ([]byte, error)

然后解析客户端证书来了解客户端,也可以考虑使用transient fields让客户把相关信息放在那里,以后可以被链代码读取:

// GetTransient returns the `ChaincodeProposalPayload.Transient` field.
// It is a map that contains data (e.g. cryptographic material)
// that might be used to implement some form of application-level
// confidentiality. The contents of this field, as prescribed by
// `ChaincodeProposalPayload`, are supposed to always
// be omitted from the transaction and excluded from the ledger.
GetTransient() (map[string][]byte, error)

关于go - 在 Hyperledger Fabric V1.0 链代码中识别调用同级/组织,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46383752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com