2

I have a scenario in which it would be required for the chaincode to call an external application to do a complex proprietary job.

I know that it is basically possible (also not recommended) to call an external service e. g. via HTTP.

However, I'd like to call a binary that is locally installed on the peer simply by for example exec.Command("some application") from the chaincode and work with its result.

The problem I am facing is that Fabric runs the chaincode itself in another docker container and not directly in the peer container, making the binary unavailable. Is there a way to share maybe a peer's volume with the runtime containers created by Fabric for chaincode execution?

Dan Anderson
  • 2,265
  • 1
  • 9
  • 20
Roper
  • 109
  • 5
  • Do you need the result of the external application to be run and verified by all endorsers? Otherwise it might be a better idea to run the binary first (i.e. on the server processing requests from your client application) and include the results as part of the transaction. In your scenario you'd otherwise have to make sure that all endorsers have access to your local program dependency. In addition, they also all need to arrive at the exact same result, or your transaction may be rejected. – Sigmatics Apr 20 '19 at 10:52

1 Answers1

1

You can package the binary with the chaincode package and then it will be able to execute it at the time of the chaincode execution.

yacovm
  • 5,120
  • 1
  • 11
  • 21
  • How would that look like, since my chaincode is only one .go file that is installed via `peer chaincode install`. Do I have any influence on which files are available in the temporary Golang runtime container? – Roper Apr 25 '19 at 09:46