Skip to content

Latest commit

 

History

History
81 lines (64 loc) · 3.47 KB

builder.md

File metadata and controls

81 lines (64 loc) · 3.47 KB

Chaincode Builder and Launcher

  • CHAINCODE_SOURCE_DIR: Contains the contents placed in src directory. This generally is the source code of the chaincode. In case of chaincode as a service, this will have a connection.json file.
  • CHAINCODE_METADATA_DIR: Contains the metadata.json file. Add the mandatory parameters to let the peer node better decide if this shall be the right builder to be used.
  • BUILD_OUTPUT_DIR: The directory where the output of the build step is stored. This will have connection.json file in case of chaincode as a server.
  • RELEASE_OUTPUT_DIR: The directory from where the peer picks up the artefacts for execution. In case of chaincode as a service, copy the connection.json file to the ${RELEASE_OUTPUT_DIR}/chaincode/server directory. The other kind of metadata that gets consumed is META-INF. It shall be placed in ${RELEASE_OUTPUT_DIR}/statedb/couchdb/indexes directory.
  • RUN_METADATA_DIR: Used in run, which is optional. This directory is populated with the connection.json file. The file has connection information for a chaincode to connect with the peer node.

The connection.json file consumed by the chaincode has the following parameters, these are populated by the peer node. Note that this is different from the connection.json that you would compose to run chaincode as a server.

{
    "client_key": "The PEM encoded client key generated by the peer that must be used when the chaincode establishes its connection to the peer.",
    "client_cert": "The PEM encoded TLS client certificate generated by the peer that must be used when the chaincode establishes its connection to the peer."
    "chaincode_id": "The unique ID associated with the chaincode package. Generated by the peer node."
    "peer_address": "The address in host:port format of the ChaincodeSupport gRPC server endpoint hosted by the peer."
    "root_cert": "The PEM encoded TLS root certificate for the ChaincodeSupport gRPC server endpoint hosted by the peer.",
    "mspid": "The local mspid of the peer."
}

Step 1: Detect

Detect if the installed chaincode shall be packaged and run using this builder definition. All the inputs to the detect command are read only.

Expectation at this step is that the code returns a success return value. Command exit status set to 0. You can consider that the peer would make a call as following

detect CHAINCODE_SOURCE_DIR CHAINCODE_METADATA_DIR

Step 2: Build

Build the source directory contents, optionally making use of metadata. Place the generated files to the output directory for later execution.

Expectation at this step is that the chaincode is built and the generated artefacts are placed in the expected output directory. You can consider that the peer would make a call as following

build CHAINCODE_SOURCE_DIR CHAINCODE_METADATA_DIR BUILD_OUTPUT_DIR

Step 3: Release

Release the artefacts for peer to consume. Copy from the build step, the artefacts that the peer can consume. Generally the peer node consumes indexes metadata and the external chaincode server information.

release BUILD_OUTPUT_DIR RELEASE_OUTPUT_DIR

Step 4: Run

Run is not required in case of chaincode as a service. However, if you are using a custom chaincode builder to run the chaincode. Then this step consumes the connection.json file generated by the peer node. This file is available in the RUN_METADATA_DIR directory.

run BUILD_OUTPUT_DIR RUN_METADATA_DIR