IBM-Blockchain / ansible-collection

Ansible collection for building Hyperledger Fabric networks
Apache License 2.0
43 stars 38 forks source link

Legacy chaincode support with invoke #591

Open paquitojc opened 2 years ago

paquitojc commented 2 years ago

I have a Legacy chaincode where I need to pass Arguments to Init function, To support legacy chaincodes there is peer chaincode invoke cli command with --isInit parameter, see it here - https://hyperledger-fabric.readthedocs.io/en/release-2.2/commands/peerchaincode.html?highlight=invoke#peer-chaincode-invoke.

mbwhite commented 2 years ago

I've reviewed the details and there is a reason why the invokes were not added. This is because it would break the idea that the Ansible Modules should be idempotent; there's no way to know if a transaction has been submitted already. other modules can be safely run repeatedly without issue - not the same with an invoke.

Having said that, this init-required is a special case, so I'll look at if it can be added to the committed_chaincode task - so that when the chaincode is committed, the init transaction is sent at the same time.

The restriction would be that if the init transaction fails and it needed resubmitting then that would need to be done by other means.

Here's the candidate PR:

https://github.com/IBM-Blockchain/ansible-collection/pull/592