how to invoke chaincode function from itself to record sub transactions

霸气de小男生 提交于 2019-12-08 02:48:21

To invoke another chaincode within your chaincode you can use

stub.InvokeChaincode(chaincodeName, queryArgs, channelName)

where channelName can be empty if you want to call chaincode in the same channel.

source: https://github.com/hyperledger/fabric/blob/release/examples/chaincode/go/chaincode_example05/chaincode_example05.go#L90

However, I think that the call will not add a new transaction because the call of another code has to be validated and you could use the result of the call to change data on the ledger base on it. So everything will end up in 1 transaction.

Also be sure to differentiate between blocks and transactions.

Block

An ordered set of transactions that is cryptographically linked to the preceding block(s) on a channel.

Transaction

Invoke or instantiate results that are submitted for ordering, validation, and commit. Invokes are requests to read/write data from the ledger. Instantiate is a request to start and initialize a chaincode on a channel. Application clients gather invoke or instantiate responses from endorsing peers and package the results and endorsements into a transaction that is submitted for ordering, validation, and commit.

http://hyperledger-fabric.readthedocs.io/en/release/glossary.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!