mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
Add a channel event handler sample based on block events. Scope: create a block event handler write events received to the console write events received to a log file write events to an off chain couchdb database demonstrate a basic map reduce view for aggregation Change-Id: I5420ddc7070dbee785218ce5960f7604ac799f90 Signed-off-by: Chris Elder <chris.elder@us.ibm.com>
113 lines
3.5 KiB
Bash
Executable file
113 lines
3.5 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Copyright IBM Corp All Rights Reserved
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Exit on first error
|
|
set -e pipefail
|
|
|
|
|
|
# don't rewrite paths for Windows Git Bash users
|
|
export MSYS_NO_PATHCONV=1
|
|
starttime=$(date +%s)
|
|
CC_SRC_LANGUAGE=${1:-"go"}
|
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
|
CC_RUNTIME_LANGUAGE=golang
|
|
CC_SRC_PATH=github.com/chaincode/marbles02/go
|
|
|
|
|
|
# clean the keystore
|
|
rm -rf ./hfc-key-store
|
|
|
|
# launch network; create channel and join peer to channel
|
|
pushd ../first-network
|
|
echo y | ./byfn.sh down
|
|
echo y | ./byfn.sh up -a -n -s couchdb
|
|
popd
|
|
|
|
CONFIG_ROOT=/opt/gopath/src/github.com/hyperledger/fabric/peer
|
|
ORG1_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
|
ORG1_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
|
|
ORG2_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
|
|
ORG2_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
|
ORDERER_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
|
|
|
echo "Installing smart contract on peer0.org1.example.com"
|
|
docker exec \
|
|
-e CORE_PEER_LOCALMSPID=Org1MSP \
|
|
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \
|
|
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \
|
|
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} \
|
|
cli \
|
|
peer chaincode install \
|
|
-n marbles \
|
|
-v 1.0 \
|
|
-p "$CC_SRC_PATH" \
|
|
-l "$CC_RUNTIME_LANGUAGE"
|
|
|
|
echo "Installing smart contract on peer1.org1.example.com"
|
|
docker exec \
|
|
-e CORE_PEER_LOCALMSPID=Org1MSP \
|
|
-e CORE_PEER_ADDRESS=peer1.org1.example.com:8051 \
|
|
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \
|
|
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} \
|
|
cli \
|
|
peer chaincode install \
|
|
-n marbles \
|
|
-v 1.0 \
|
|
-p "$CC_SRC_PATH" \
|
|
-l "$CC_RUNTIME_LANGUAGE"
|
|
|
|
echo "Installing smart contract on peer0.org2.example.com"
|
|
docker exec \
|
|
-e CORE_PEER_LOCALMSPID=Org2MSP \
|
|
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051 \
|
|
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH} \
|
|
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE} \
|
|
cli \
|
|
peer chaincode install \
|
|
-n marbles \
|
|
-v 1.0 \
|
|
-p "$CC_SRC_PATH" \
|
|
-l "$CC_RUNTIME_LANGUAGE"
|
|
|
|
echo "Installing smart contract on peer1.org2.example.com"
|
|
docker exec \
|
|
-e CORE_PEER_LOCALMSPID=Org2MSP \
|
|
-e CORE_PEER_ADDRESS=peer1.org2.example.com:10051 \
|
|
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH} \
|
|
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE} \
|
|
cli \
|
|
peer chaincode install \
|
|
-n marbles \
|
|
-v 1.0 \
|
|
-p "$CC_SRC_PATH" \
|
|
-l "$CC_RUNTIME_LANGUAGE"
|
|
|
|
echo "Instantiating smart contract on mychannel"
|
|
docker exec \
|
|
-e CORE_PEER_LOCALMSPID=Org1MSP \
|
|
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} \
|
|
cli \
|
|
peer chaincode instantiate \
|
|
-o orderer.example.com:7050 \
|
|
-C mychannel \
|
|
-n marbles \
|
|
-l "$CC_RUNTIME_LANGUAGE" \
|
|
-v 1.0 \
|
|
-c '{"Args":[]}' \
|
|
-P "AND('Org1MSP.member','Org2MSP.member')" \
|
|
--tls \
|
|
--cafile ${ORDERER_TLS_ROOTCERT_FILE} \
|
|
--peerAddresses peer0.org1.example.com:7051 \
|
|
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE}
|
|
|
|
echo "Waiting for instantiation request to be committed ..."
|
|
sleep 10
|
|
|
|
cat <<EOF
|
|
|
|
Total setup execution time : $(($(date +%s) - starttime)) secs ...
|
|
|
|
EOF
|