|
1 | | -#!/bin/bash |
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -eu |
| 4 | + |
| 5 | +echo "Checking if chaincode is installed and running..." |
| 6 | + |
| 7 | +if ! docker exec peer0.org1.example.com peer chaincode list --installed 2>/dev/null | grep -q "simple-asset"; then |
| 8 | + echo "ERROR: Chaincode 'simple-asset' is not installed on the peer." |
| 9 | + echo "Please install the chaincode first" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | + |
| 14 | +if ! docker exec peer0.org1.example.com peer chaincode list --instantiated -C mychannel 2>/dev/null | grep -q "simple-asset"; then |
| 15 | + echo "ERROR: Chaincode 'simple-asset' is not committed to the channel." |
| 16 | + echo "Please commit the chaincode first." |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
2 | 20 |
|
3 | | -# Build the chaincode (using shadowJar) |
4 | 21 | ./gradlew clean shadowJar |
5 | 22 |
|
| 23 | +if [ ! -f "build/libs/java-chaincode-1.0-SNAPSHOT-all.jar" ]; then |
| 24 | + echo "Error: JAR file was not created. Build may have failed." |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +if ! docker ps | grep -q "peer0.org1.example.com"; then |
| 29 | + echo "Error: peer0.org1.example.com container is not running." |
| 30 | + echo "Please make sure the Fabric network is up and running." |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | + |
| 34 | +# Get the IP address of peer0.org1.example.com |
6 | 35 | peer_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' peer0.org1.example.com) |
7 | 36 | if [ -z "$peer_ip" ]; then |
8 | 37 | echo "Error: Could not find peer0.org1.example.com IP address." |
9 | 38 | exit 1 |
10 | 39 | fi |
11 | 40 | # Run the chaincode in dev mode |
12 | 41 | CORE_CHAINCODE_LOGLEVEL=debug \ |
13 | | -CORE_PEER_TLS_ENABLED= true \ |
| 42 | +CORE_PEER_TLS_ENABLED=true \ |
14 | 43 | CORE_CHAINCODE_ID_NAME=simple-asset:1.0 \ |
15 | 44 | CORE_PEER_ADDRESS=$peer_ip:7051 \ |
| 45 | +CORE_CHAINCODE_LOGGING_LEVEL=DEBUG \ |
| 46 | +CORE_CHAINCODE_LOGGING_SHIM=debug \ |
16 | 47 | java -jar build/libs/java-chaincode-1.0-SNAPSHOT-all.jar |
0 commit comments