mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Split boiler-plate connection code into a separate file since the basic sample already covers this aspect. The `app.go` file now only presents the main application code, making it much easier for readers to view. Also changed the event replay code to use a different style of reading from the real-time eventing example, demonstrating the use of timeouts while reading events we expect to arrive quickly, and avoiding any possibility of the main application execution hanging indefinitely. Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
45 lines
1.1 KiB
Bash
Executable file
45 lines
1.1 KiB
Bash
Executable file
set -euo pipefail
|
|
|
|
CHAINCODE_LANGUAGE=${CHAINCODE_LANGUAGE:-javascript}
|
|
CHAINCODE_NAME=${CHAINCODE_NAME:-events}
|
|
CHAINCODE_PATH=${CHAINCODE_PATH:-../asset-transfer-events}
|
|
|
|
function print() {
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
echo
|
|
echo -e "${GREEN}${1}${NC}"
|
|
}
|
|
|
|
function createNetwork() {
|
|
print "Creating network"
|
|
./network.sh up createChannel -ca
|
|
print "Deploying ${CHAINCODE_NAME} chaincode"
|
|
./network.sh deployCC -ccn "${CHAINCODE_NAME}" -ccp "${CHAINCODE_PATH}/chaincode-${CHAINCODE_LANGUAGE}" -ccl "${CHAINCODE_LANGUAGE}" -ccep "OR('Org1MSP.peer','Org2MSP.peer')"
|
|
}
|
|
|
|
function stopNetwork() {
|
|
print "Stopping network"
|
|
./network.sh down
|
|
}
|
|
|
|
# Run Javascript application
|
|
createNetwork
|
|
print "Initializing Javascript application"
|
|
pushd ../asset-transfer-events/application-javascript
|
|
npm install
|
|
print "Executing app.js"
|
|
node app.js
|
|
popd
|
|
stopNetwork
|
|
print "Remove wallet storage"
|
|
rm -R ../asset-transfer-events/application-javascript/wallet
|
|
|
|
# Run Go gateway application
|
|
createNetwork
|
|
print "Initializing Go gateway application"
|
|
pushd ../asset-transfer-events/application-gateway-go
|
|
print "Executing application"
|
|
go run .
|
|
popd
|
|
stopNetwork
|