Update configs

pull/108/head
Baohua Yang 2017-11-01 16:56:04 +08:00
parent 8e9bf1bc94
commit fce22758d9
7 changed files with 149 additions and 47 deletions

View File

@ -2,7 +2,7 @@ KAFKA_ENABLED ?= false
COUCHDB_ENABLED ?= false COUCHDB_ENABLED ?= false
DEV_ENABLED ?= false DEV_ENABLED ?= false
COMPOSE_FILE ?= "docker-compose-2orgs-4peers.yaml" COMPOSE_FILE ?= "docker-compose-2orgs-4peers-solo.yaml"
ifeq ($(KAFKA_ENABLED),true) ifeq ($(KAFKA_ENABLED),true)
COMPOSE_FILE="docker-compose-2orgs-4peers-kafka.yaml" COMPOSE_FILE="docker-compose-2orgs-4peers-kafka.yaml"

View File

@ -1,4 +1,5 @@
# Base compose files for: # All elements in this file should depend on the base.yaml
# Provided solo-base fabric network with:
# ca.org1.example.com # ca.org1.example.com
# ca.org2.example.com # ca.org2.example.com
@ -12,13 +13,14 @@
version: '2' # v3 does not support 'extends' yet version: '2' # v3 does not support 'extends' yet
services: services:
ca.org1.example.com: ca.org1.example.com: # ca node for org1
extends: extends:
file: base.yaml file: base.yaml
service: ca-base service: ca-base
container_name: ca.org1.example.com container_name: ca.org1.example.com
hostname: ca.org1.example.com hostname: ca.org1.example.com
environment: environment:
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_CA_NAME=ca-org1 - FABRIC_CA_SERVER_CA_NAME=ca-org1
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/c843d3f021118963ce5d340e95286e8869bb7bd051454cd4166aa2887a2ad451_sk - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/c843d3f021118963ce5d340e95286e8869bb7bd051454cd4166aa2887a2ad451_sk
@ -28,13 +30,14 @@ services:
- ./solo/crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config - ./solo/crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/c843d3f021118963ce5d340e95286e8869bb7bd051454cd4166aa2887a2ad451_sk -b admin:adminpw -d' command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/c843d3f021118963ce5d340e95286e8869bb7bd051454cd4166aa2887a2ad451_sk -b admin:adminpw -d'
ca.org2.example.com: ca.org2.example.com: # ca node for org2
extends: extends:
file: base.yaml file: base.yaml
service: ca-base service: ca-base
container_name: ca.org2.example.com container_name: ca.org2.example.com
hostname: ca.org2.example.com hostname: ca.org2.example.com
environment: environment:
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_CA_NAME=ca-org2 - FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/1ee551a8753171c0377366e96a1d7ec01afddb868c9483cc501b6f8ac7ae752f_sk - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/1ee551a8753171c0377366e96a1d7ec01afddb868c9483cc501b6f8ac7ae752f_sk
@ -44,12 +47,14 @@ services:
- ./solo/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config - ./solo/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/1ee551a8753171c0377366e96a1d7ec01afddb868c9483cc501b6f8ac7ae752f_sk -b admin:adminpw -d' command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/1ee551a8753171c0377366e96a1d7ec01afddb868c9483cc501b6f8ac7ae752f_sk -b admin:adminpw -d'
orderer.example.com: # There can be multiple orderers orderer.example.com: # orderer node for example org
extends: extends:
file: base.yaml file: base.yaml
service: orderer-base service: orderer-base
container_name: orderer.example.com container_name: orderer.example.com
hostname: orderer.example.com hostname: orderer.example.com
environment:
- ORDERER_GENERAL_TLS_ENABLED=true
ports: ports:
- "7050:7050" - "7050:7050"
volumes: volumes:
@ -58,7 +63,7 @@ services:
- ./solo/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls - ./solo/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
command: orderer start command: orderer start
cli: cli: # client node
extends: extends:
file: base.yaml file: base.yaml
service: cli-base service: cli-base
@ -74,6 +79,7 @@ services:
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
- CORE_PEER_TLS_ENABLED=true # to enable TLS, change to true
volumes: volumes:
#- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ #- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./scripts:/tmp/scripts - ./scripts:/tmp/scripts
@ -97,6 +103,7 @@ services:
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052 - CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP - CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true
volumes: volumes:
- ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp - ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls - ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
@ -118,6 +125,7 @@ services:
- CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7052 - CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP - CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true
volumes: volumes:
- ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp - ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls - ./solo/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
@ -139,6 +147,7 @@ services:
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052 - CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP - CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_TLS_ENABLED=true
volumes: volumes:
- ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp - ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls - ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
@ -160,10 +169,40 @@ services:
- CORE_PEER_CHAINCODELISTENADDRESS=peer1.org2.example.com:7052 - CORE_PEER_CHAINCODELISTENADDRESS=peer1.org2.example.com:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP - CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_TLS_ENABLED=true
volumes: volumes:
- ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp - ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls - ./solo/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports: ports:
- 10051:7051 - 10051:7051
- 10052:7052 - 10052:7052
- 10053:7053 - 10053:7053
event-listener:
extends:
file: base.yaml
service: event-listener-base
container_name: fabric-event-listener
hostname: fabric-event-listener
environment:
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051 # default to operate on peer0.org1
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
volumes:
#- ./solo/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples
- ./solo/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./solo/channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
- ./solo/configtx.yaml:/etc/hyperledger/fabric/configtx.yaml
- ./solo/crypto-config.yaml:/etc/hyperledger/fabric/crypto-config.yaml
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
depends_on:
- orderer.example.com
- peer0.org1.example.com
- peer1.org1.example.com
- peer0.org2.example.com
- peer1.org2.example.com
#command: bash -c 'block-listener -events-address=peer0.org1.example.com:7053 -events-mspdir=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/ -events-mspid=Org1MSP'
command: bash -c 'while true; do sleep 20170504; done'

View File

@ -1,5 +1,5 @@
# This is the default base file to config env and command # This is the default base file to config env and command
# Notice that chaincode is executed inside docker in default net mode # All element in this file is abstract without knowing the org and consensus type
# https://github.com/yeasy/docker-compose-files # https://github.com/yeasy/docker-compose-files
# Depends on the hyperledger/fabric-peer image. # Depends on the hyperledger/fabric-peer image.
@ -14,6 +14,7 @@ services:
environment: environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_TLS_ENABLED=true - FABRIC_CA_SERVER_TLS_ENABLED=true
#- FABRIC_CA_SERVER_TLS_ENABLED=false
orderer-base: orderer-base:
#image: yeasy/hyperledger-fabric-orderer:1.0.3 #image: yeasy/hyperledger-fabric-orderer:1.0.3
@ -28,7 +29,7 @@ services:
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
- ORDERER_GENERAL_LEDGERTYPE=file - ORDERER_GENERAL_LEDGERTYPE=file
- ORDERER_GENERAL_BATCHTIMEOUT=2s - ORDERER_GENERAL_BATCHTIMEOUT=1s
- ORDERER_GENERAL_MAXMESSAGECOUNT=10 - ORDERER_GENERAL_MAXMESSAGECOUNT=10
- ORDERER_GENERAL_MAXWINDOWSIZE=1000 - ORDERER_GENERAL_MAXWINDOWSIZE=1000
- ORDERER_GENERAL_LISTENPORT=7050 - ORDERER_GENERAL_LISTENPORT=7050
@ -90,7 +91,19 @@ services:
- ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem - ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
- CHANNEL_NAME:="businesschannel" - CHANNEL_NAME:="businesschannel"
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: bash -c 'cd /tmp; bash scripts/func.sh; while true; do sleep 20170504; done' command: bash -c 'cd /tmp; source scripts/func.sh; while true; do sleep 20170504; done'
event-listener-base:
image: yeasy/hyperledger-fabric:1.0.3
restart: always
tty: true
environment:
- CORE_PEER_ID=fabric-event-listener
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=false # event-listener doesn't support TLS
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
#command: bash -c 'block-listener -events-address=peer0.org1.example.com:7053 -events-mspdir=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/ -events-mspid=Org1MSP'
command: bash -c 'while true; do sleep 20170504; done'
couchdb-base: couchdb-base:
#container_name: couchdb0 #container_name: couchdb0
@ -110,6 +123,8 @@ services:
- '3888' - '3888'
kafka-base: kafka-base:
# official repo doesn't have latest tag, however, kafka changes version recently
image: yeasy/hyperledger-fabric-kafka:0.10.2.0
image: hyperledger/fabric-kafka:x86_64-1.0.3 image: hyperledger/fabric-kafka:x86_64-1.0.3
restart: always restart: always
tty: true tty: true

View File

@ -10,42 +10,42 @@ version: '2.0'
services: services:
# ca.org1.example.com: # ca.org1.example.com:
# extends: # extends:
# file: docker-compose-base-e2e.yaml # file: base-solo.yaml
# service: ca.org1.example.com # service: ca.org1.example.com
# ca.org2.example.com: # ca.org2.example.com:
# extends: # extends:
# file: docker-compose-base-e2e.yaml # file: base-solo.yaml
# service: ca.org2.example.com # service: ca.org2.example.com
cli: cli:
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: cli service: cli
orderer.example.com: # There can be multiple orderers orderer.example.com: # There can be multiple orderers
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: orderer.example.com service: orderer.example.com
peer0.org1.example.com: peer0.org1.example.com:
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: peer0.org1.example.com service: peer0.org1.example.com
peer1.org1.example.com: peer1.org1.example.com:
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: peer1.org1.example.com service: peer1.org1.example.com
peer0.org2.example.com: peer0.org2.example.com:
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: peer0.org2.example.com service: peer0.org2.example.com
peer1.org2.example.com: peer1.org2.example.com:
extends: extends:
file: docker-compose-base-e2e.yaml file: base-solo.yaml
service: peer1.org2.example.com service: peer1.org2.example.com
#networks: #networks:

View File

@ -27,14 +27,13 @@ ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrga
verifyResult () { verifyResult () {
if [ $1 -ne 0 ] ; then if [ $1 -ne 0 ] ; then
echo_b "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!" echo_b "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
echo_r "================== ERROR !!! FAILED to execute End-2-End Scenario ==================" echo_r "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
echo echo
exit 1 exit 1
fi fi
} }
setGlobals () { setGlobals () {
if [ $1 -eq 0 -o $1 -eq 1 ] ; then if [ $1 -eq 0 -o $1 -eq 1 ] ; then
CORE_PEER_LOCALMSPID="Org1MSP" CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
@ -89,6 +88,8 @@ checkOSNAvailability() {
# Use peer0/org1 to create a channel # Use peer0/org1 to create a channel
channelCreate() { channelCreate() {
CHANNEL_NAME=$1
echo_b "===================== Create Channel \"$CHANNEL_NAME\" ===================== "
setGlobals 0 setGlobals 0
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --timeout $TIMEOUT >&log.txt peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --timeout $TIMEOUT >&log.txt
@ -111,10 +112,11 @@ channelCreate() {
} }
updateAnchorPeers() { updateAnchorPeers() {
PEER=$1 CHANNEL_NAME=$1
setGlobals $PEER PEER=$2
setGlobals $PEER
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then echo_b "===================== Update Anchor peers for org \"$CORE_PEER_LOCALMSPID\" on \"$CHANNEL_NAME\" ===================== "
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
else else
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
@ -122,7 +124,7 @@ updateAnchorPeers() {
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Anchor peer update failed" verifyResult $res "Anchor peer update failed"
echo "===================== Anchor peers for org \"$CORE_PEER_LOCALMSPID\" on \"$CHANNEL_NAME\" is updated successfully ===================== " echo_g "===================== Anchor peers for org \"$CORE_PEER_LOCALMSPID\" on \"$CHANNEL_NAME\" is updated successfully ===================== "
sleep 5 sleep 5
echo echo
} }
@ -145,11 +147,13 @@ joinWithRetry () {
# Join given (by default all) peers into the channel # Join given (by default all) peers into the channel
channelJoin () { channelJoin () {
peer_to_join=$(seq 0 3) CHANNEL_NAME=$1
if [ $# -gt 0 ]; then echo_b "===================== Join peers into the channel \"$CHANNEL_NAME\" ===================== "
peer_to_join=$@ peers_to_join=$(seq 0 3)
if [ $# -gt 1 ]; then
peers_to_join=${@:2}
fi fi
for i in $peer_to_join; do for i in $peers_to_join; do
setGlobals $i setGlobals $i
joinWithRetry $i joinWithRetry $i
echo_g "===================== PEER$i joined on the channel \"$CHANNEL_NAME\" ===================== " echo_g "===================== PEER$i joined on the channel \"$CHANNEL_NAME\" ===================== "
@ -160,8 +164,10 @@ channelJoin () {
# Instantiate chaincode on specifized peer node # Instantiate chaincode on specifized peer node
chaincodeInstantiate () { chaincodeInstantiate () {
#CHANNEL_NAME=$1
PEER=$1 PEER=$1
setGlobals $PEER setGlobals $PEER
echo_b "===================== chaincodeInstantiate for channel $CHANNEL_NAME on peer $PEER ============"
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful), # while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option # lets supply it directly as we know it using the "-o" option
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
@ -171,14 +177,14 @@ chaincodeInstantiate () {
fi fi
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Chaincode instantiation on PEER$PEER on channel '$CHANNEL_NAME' failed" verifyResult $res "Chaincode instantiation on PEER$PEER in channel '$CHANNEL_NAME' failed"
echo_g "===================== Chaincode Instantiation on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo_g "===================== Chaincode Instantiation on PEER$PEER in channel '$CHANNEL_NAME' is successful ===================== "
echo echo
} }
chaincodeQuery () { chaincodeQuery () {
PEER=$1 PEER=$1
echo_b "===================== Querying on PEER$PEER on channel '$CHANNEL_NAME'... ===================== " echo_b "===================== Querying on PEER$PEER in channel '$CHANNEL_NAME'... ===================== "
setGlobals $PEER setGlobals $PEER
local rc=1 local rc=1
local starttime=$(date +%s) local starttime=$(date +%s)
@ -196,7 +202,7 @@ chaincodeQuery () {
echo echo
cat log.txt cat log.txt
if test $rc -eq 0 ; then if test $rc -eq 0 ; then
echo_g "===================== Query on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo_g "===================== Query on PEER$PEER in channel '$CHANNEL_NAME' is successful ===================== "
else else
echo_r "!!!!!!!!!!!!!!! Query result on PEER$PEER is INVALID !!!!!!!!!!!!!!!!" echo_r "!!!!!!!!!!!!!!! Query result on PEER$PEER is INVALID !!!!!!!!!!!!!!!!"
echo_r "================== ERROR !!! FAILED to execute End-2-End Scenario ==================" echo_r "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
@ -207,6 +213,7 @@ chaincodeQuery () {
chaincodeInvoke () { chaincodeInvoke () {
PEER=$1 PEER=$1
echo_g "===================== Invoke transaction on PEER$PEER in channel '$CHANNEL_NAME'===================== "
setGlobals $PEER setGlobals $PEER
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful), # while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option # lets supply it directly as we know it using the "-o" option
@ -218,13 +225,14 @@ chaincodeInvoke () {
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Invoke execution on PEER$PEER failed " verifyResult $res "Invoke execution on PEER$PEER failed "
echo_g "===================== Invoke transaction on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo_g "===================== Invoke transaction on PEER$PEER in channel '$CHANNEL_NAME' is successful ===================== "
echo echo
} }
# Install chaincode on specifized peer node # Install chaincode on specifized peer node
chaincodeInstall () { chaincodeInstall () {
PEER=$1 PEER=$1
echo_b "===================== Install Chaincode on remote peer PEER$PEER ===================== "
VERSION=$2 VERSION=$2
setGlobals $PEER setGlobals $PEER
peer chaincode install -n $CC_NAME -v $VERSION -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >&log.txt peer chaincode install -n $CC_NAME -v $VERSION -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 >&log.txt
@ -235,11 +243,29 @@ chaincodeInstall () {
echo echo
} }
# chaincodeUpgrade 0 1.1 # Start chaincode with dev mode
chaincodeUpgrade () { chaincodeStartDev () {
PEER=$1 PEER=$1
VERSION=$2 VERSION=$2
setGlobals $PEER setGlobals $PEER
CORE_CHAINCODE_LOGLEVEL=debug \
CORE_PEER_ADDRESS=peer${PEER}.org1.example.com:7052 \
CORE_CHAINCODE_ID_NAME=mycc:${VERSION} \
nohup ./scripts/chaincode_example02 > chaincode_dev.log &
res=$?
cat log.txt
verifyResult $res "Chaincode start in dev mode has Failed"
echo_g "===================== Chaincode started in dev mode ===================== "
echo
}
# chaincodeUpgrade 0 1.1
chaincodeUpgrade () {
CHANNEL_NAME=$1
PEER=$2
VERSION=$3
echo_b "===================== Upgrade chaincode to version $VERSION on PEER$PEER in channel '$CHANNEL_NAME' ===================== "
setGlobals $PEER
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful), # while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option # lets supply it directly as we know it using the "-o" option
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
@ -250,7 +276,31 @@ chaincodeUpgrade () {
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "Upgrade execution on PEER$PEER failed " verifyResult $res "Upgrade execution on PEER$PEER failed "
echo_g "===================== Upgrade transaction on PEER$PEER on channel '$CHANNEL_NAME' is successful ===================== " echo_g "===================== Upgrade transaction on PEER$PEER in channel '$CHANNEL_NAME' is successful ===================== "
echo echo
} }
channelFetch () {
PEER=$1
BLOCK_NO=$2
echo_b "===================== Fetch block $BLOCK_NO on PEER$PEER in channel '$CHANNEL_NAME' ===================== "
setGlobals $PEER
# while 'peer chaincode' command can get the orderer endpoint from the peer (if join was successful),
# lets supply it directly as we know it using the "-o" option
if [ -z "${CORE_PEER_TLS_ENABLED}" -o "${CORE_PEER_TLS_ENABLED}" = "false" ]; then
peer channel fetch $BLOCK_NO \
-o orderer.example.com:7050 \
-c ${CHANNEL_NAME} >&log.txt
else
peer channel fetch $BLOCK_NO block_${BLOCK_NO}.block \
-o orderer.example.com:7050 \
-c $CHANNEL_NAME \
--tls \
--cafile $ORDERER_CA >&log.txt
fi
res=$?
cat log.txt
verifyResult $res "Fetch block on PEER$PEER failed "
echo_g "===================== Fetch block on PEER$PEER in channel '$CHANNEL_NAME' is successful ===================== "
echo
}

View File

@ -13,22 +13,20 @@ echo " ==========initialize businesschannel========== "
echo " ============================================== " echo " ============================================== "
echo echo
echo_b "Channel name : "$CHANNEL_NAME
## Create channel ## Create channel
echo_b "Creating channel..." echo_b "Creating channel $CHANNEL_NAME..."
channelCreate channelCreate $CHANNEL_NAME
## Join all the peers to the channel ## Join all the peers to the channel
echo_b "Having all peers join the channel..." echo_b "Having all peers join the channel $CHANNEL_NAME..."
channelJoin channelJoin $CHANNEL_NAME
## Set the anchor peers for each org in the channel ## Set the anchor peers for each org in the channel
echo_b "Updating anchor peers for org1..." echo_b "Updating anchor peers for org1..."
updateAnchorPeers 0 updateAnchorPeers $CHANNEL_NAME 0
echo_b "Updating anchor peers for org2..." echo_b "Updating anchor peers for org2..."
updateAnchorPeers 2 updateAnchorPeers $CHANNEL_NAME 2
## Install chaincode on all peers ## Install chaincode on all peers
echo_b "Installing chaincode on all 4 peers..." echo_b "Installing chaincode on all 4 peers..."
@ -39,7 +37,7 @@ chaincodeInstall 3 1.0
# Instantiate chaincode on all peers # Instantiate chaincode on all peers
# Instantiate can only be executed once on any node # Instantiate can only be executed once on any node
echo_b "Instantiating chaincode on all 2 channels (once for each channel)..." echo_b "Instantiating chaincode on all 2 orgs (once for each org)..."
chaincodeInstantiate 0 chaincodeInstantiate 0
chaincodeInstantiate 2 chaincodeInstantiate 2

View File

@ -37,7 +37,7 @@ chaincodeInstall 1 1.1
chaincodeInstall 2 1.1 chaincodeInstall 2 1.1
chaincodeInstall 3 1.1 chaincodeInstall 3 1.1
chaincodeUpgrade 0 1.1 chaincodeUpgrade $CHANNEL_NAME 0 1.1
chaincodeQuery 0 100 chaincodeQuery 0 100
chaincodeQuery 3 100 chaincodeQuery 3 100