从Hyperledger Fabric Node SDK中的函数InvokeChaincode()获取链码调用方ID [英] Get chaincode caller ID from the function InvokeChaincode() in Hyperledger Fabric Node SDK

查看:509
本文介绍了从Hyperledger Fabric Node SDK中的函数InvokeChaincode()获取链码调用方ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设以下网络体系结构:

Let's suppose the following network architecture:

A -> Chaincode1 -> fabcar

A 是应用程序, Chaincode1 是Go中的链代码,而 fabcar 是Node.js中的链代码. 它们在同一频道:"mychannel".

A is the application, Chaincode1 is a chaincode in Go and fabcar is a chaincode in Nodejs. They are on the same channel: "mychannel".

Chaincode1 (例如APIstub.InvokeChaincode("fabcar", chainCodeArgs, "mychannel"))执行APIstub.InvokeChaincode操作时,链代码 fabcar (称为链代码)有可能获得呼叫者链码的 id ?

When is performed the operation APIstub.InvokeChaincode from the Chaincode1 such as APIstub.InvokeChaincode("fabcar", chainCodeArgs, "mychannel"), is there a possibility for the chaincode fabcar (the chaincode called) to get the id of the the caller chaincode?

fabcar 链代码中的getCreator()方法仅返回调用者组织;但是所需的信息是 chaincode id 或仅与 Chaincode1 相关的某些信息.

The getCreator() method in the fabcar chaincode just returns the caller organization; but the information needed is the chaincode id or some info only connected to the Chaincode1.

更新

我尝试了Hyperledger官方文档中所写的getSignedProposal()方法: https://fabric-shim.github.io/ChaincodeStub.html#getSignedProposal__anchor

I tryed the getSignedProposal() method as written in the official documentation of hyperledger: https://fabric-shim.github.io/ChaincodeStub.html#getSignedProposal__anchor

getSignedProposal()方法返回类型为SignedProposal的已签名交易建议的完全解码对象. SignedProposal对象代表客户端应用程序发送到链码的请求对象.

The getSignedProposal() method returns a fully decoded object of the signed transaction proposal of type SignedProposal. The SignedProposal object represents the request object sent by the client application to the chaincode.

执行以下代码:

const proposal = stub.getSignedProposal();
console.log("signed proposal: ", proposal);

结果如下:

signed proposal:  { signature: <Buffer 30 45 02 21 00 c3 a7 91 4c 74 f9 c2 97 04 fc 84 91 6a 71 2d 69 ad 0e a9 22 f2 ed 53 a3 66 97 56 17 d7 d7 3a e6 02 20 13 26 8a 4f f6 3d 86 4e f9 35 ae ... >,
  proposal:
   { header: { signature_header: [Object], channel_header: [Object] },
     payload: { input: [Object], TransientMap: [Object] } } }

似乎真的很难理解,这是可以检索呼叫链代码ID 的信息. 这是与SignedProposal类型有关的文档链接: https://fabric-shim .github.io/global.html#SignedProposal

Seems really difficult to understand which is the info where is possible to retrieve the calling chaincode ID. Here is the link of the doc concerning the SignedProposal type: https://fabric-shim.github.io/global.html#SignedProposal

推荐答案

否,当前无法执行此操作,因为链码本身没有身份.

No, it is not currently possible to do this because the chaincode itself does not have an identity, per se.

这篇关于从Hyperledger Fabric Node SDK中的函数InvokeChaincode()获取链码调用方ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆