fabric-contract-api-go中有一种获取交易发起者身份的方法
func (ctx *TransactionContext) GetClientIdentity() cid.ClientIdentity
在此合同create
中调用例如,https://github.com/hyperledger/fabric-contract-api-go/blob/master/tutorials/getting-started.md时,我们如何使用它返回客户ID”>
// ...
// ...
// Create adds a new key with value to the world state
func (sc *SimpleContract) Create(ctx contractapi.TransactionContextInterface, key string, value string) error {
existing, err := ctx.GetStub().GetState(key)
if err != nil {
return errors.New("Unable to interact with world state")
}
if existing != nil {
return fmt.Errorf("Cannot create world state pair with key %s. Already exists", key)
}
err = ctx.GetStub().PutState(key, []byte(value))
if err != nil {
return errors.New("Unable to interact with world state")
}
return nil
}
// ...
// ...
fabric-contract-api-go中有一种用于获取事务发起方的身份函数(ctx * TransactionContext)GetClientIdentity()cid.ClientIdentity的方法,当...时,我们如何使用它返回客户端ID,...
GetClientIdentity
返回您此处定义的ClientIdentity类型的接口https://github.com/hyperledger/fabric-chaincode-go/blob/master/pkg/cid/interfaces.go这显示了您可以调用的功能,以检索有关事务提交者的信息(即客户身份)]