mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
WIP
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
This commit is contained in:
parent
f4c439ce8a
commit
dc4dcd482e
8 changed files with 121 additions and 217 deletions
|
|
@ -15,6 +15,12 @@ export PATH=${PWD}/../../bin:${PWD}:$PATH
|
|||
export FABRIC_CFG_PATH=${PWD}
|
||||
export VERBOSE=false
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
# Print the usage message
|
||||
function printHelp () {
|
||||
echo "Usage: "
|
||||
|
|
@ -70,10 +76,8 @@ function generateOrg3() {
|
|||
echo "############ Create Org1 Identities ######################"
|
||||
echo "##########################################################"
|
||||
|
||||
set -x
|
||||
cryptogen generate --config=org3-crypto.yaml --output="../organizations"
|
||||
execute cryptogen generate --config=org3-crypto.yaml --output="../organizations"
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate certificates..."
|
||||
exit 1
|
||||
|
|
@ -127,15 +131,13 @@ function generateOrg3Definition() {
|
|||
echo "##########################################################"
|
||||
echo "####### Generating Org3 organization definition #########"
|
||||
echo "##########################################################"
|
||||
export FABRIC_CFG_PATH=$PWD
|
||||
set -x
|
||||
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate Org3 config material..."
|
||||
exit 1
|
||||
fi
|
||||
export FABRIC_CFG_PATH=$PWD
|
||||
execute configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
|
||||
res=$?
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate Org3 config material..."
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
function createOrg3 {
|
||||
|
||||
echo
|
||||
echo "Enroll the CA admin"
|
||||
echo
|
||||
|
|
@ -11,9 +14,7 @@ function createOrg3 {
|
|||
# rm -rf $FABRIC_CA_CLIENT_HOME/fabric-ca-client-config.yaml
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/msp
|
||||
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
echo 'NodeOUs:
|
||||
Enable: true
|
||||
|
|
@ -33,23 +34,17 @@ function createOrg3 {
|
|||
echo
|
||||
echo "Register peer0"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register user"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register the org admin"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers
|
||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com
|
||||
|
|
@ -57,18 +52,14 @@ function createOrg3 {
|
|||
echo
|
||||
echo "## Generate the peer0 msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml
|
||||
|
||||
echo
|
||||
echo "## Generate the peer0-tls certificates"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
|
||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/* ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
||||
|
|
@ -90,9 +81,7 @@ function createOrg3 {
|
|||
echo
|
||||
echo "## Generate the user msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp/config.yaml
|
||||
|
||||
|
|
@ -101,10 +90,7 @@ function createOrg3 {
|
|||
echo
|
||||
echo "## Generate the org admin msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||
|
||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@ function printHelp() {
|
|||
echo " network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript"
|
||||
}
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
# Obtain CONTAINER_IDS and remove them
|
||||
# TODO Might want to make this optional - could clear other containers
|
||||
# This function is called when you bring a network down
|
||||
|
|
@ -211,10 +217,8 @@ function createOrgs() {
|
|||
echo "############ Create Org1 Identities ######################"
|
||||
echo "##########################################################"
|
||||
|
||||
set -x
|
||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations"
|
||||
execute cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations"
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo $'\e[1;32m'"Failed to generate certificates..."$'\e[0m'
|
||||
exit 1
|
||||
|
|
@ -224,10 +228,8 @@ function createOrgs() {
|
|||
echo "############ Create Org2 Identities ######################"
|
||||
echo "##########################################################"
|
||||
|
||||
set -x
|
||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations"
|
||||
execute cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations"
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo $'\e[1;32m'"Failed to generate certificates..."$'\e[0m'
|
||||
exit 1
|
||||
|
|
@ -237,10 +239,8 @@ function createOrgs() {
|
|||
echo "############ Create Orderer Org Identities ###############"
|
||||
echo "##########################################################"
|
||||
|
||||
set -x
|
||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations"
|
||||
execute cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations"
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo $'\e[1;32m'"Failed to generate certificates..."$'\e[0m'
|
||||
exit 1
|
||||
|
|
@ -326,10 +326,8 @@ function createConsortium() {
|
|||
|
||||
# Note: For some unknown reason (at least for now) the block file can't be
|
||||
# named orderer.genesis.block or the orderer will fail to launch!
|
||||
set -x
|
||||
configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
|
||||
execute configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo $'\e[1;32m'"Failed to generate orderer genesis block..."$'\e[0m'
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
function createOrg1 {
|
||||
|
||||
echo
|
||||
echo "Enroll the CA admin"
|
||||
echo
|
||||
mkdir -p organizations/peerOrganizations/org1.example.com/
|
||||
|
||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/fabric-ca-client-config.yaml
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/msp
|
||||
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://admin:adminpw@localhost:7054 --caname ca-org1 --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://admin:adminpw@localhost:7054 --caname ca-org1 --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
echo 'NodeOUs:
|
||||
Enable: true
|
||||
|
|
@ -33,23 +32,17 @@ function createOrg1 {
|
|||
echo
|
||||
echo "Register peer0"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register user"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register the org admin"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
mkdir -p organizations/peerOrganizations/org1.example.com/peers
|
||||
mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com
|
||||
|
|
@ -57,18 +50,14 @@ function createOrg1 {
|
|||
echo
|
||||
echo "## Generate the peer0 msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml
|
||||
|
||||
echo
|
||||
echo "## Generate the peer0-tls certificates"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/tlscacerts/* ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
|
||||
|
|
@ -90,9 +79,7 @@ function createOrg1 {
|
|||
echo
|
||||
echo "## Generate the user msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/config.yaml
|
||||
|
||||
|
|
@ -101,9 +88,7 @@ function createOrg1 {
|
|||
echo
|
||||
echo "## Generate the org admin msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml
|
||||
|
||||
|
|
@ -111,19 +96,14 @@ function createOrg1 {
|
|||
|
||||
|
||||
function createOrg2 {
|
||||
|
||||
echo
|
||||
echo "Enroll the CA admin"
|
||||
echo
|
||||
mkdir -p organizations/peerOrganizations/org2.example.com/
|
||||
|
||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/fabric-ca-client-config.yaml
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/msp
|
||||
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://admin:adminpw@localhost:8054 --caname ca-org2 --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://admin:adminpw@localhost:8054 --caname ca-org2 --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
echo 'NodeOUs:
|
||||
Enable: true
|
||||
|
|
@ -143,23 +123,17 @@ function createOrg2 {
|
|||
echo
|
||||
echo "Register peer0"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register user"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register the org admin"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
mkdir -p organizations/peerOrganizations/org2.example.com/peers
|
||||
mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com
|
||||
|
|
@ -167,19 +141,14 @@ function createOrg2 {
|
|||
echo
|
||||
echo "## Generate the peer0 msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml
|
||||
|
||||
echo
|
||||
echo "## Generate the peer0-tls certificates"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
|
||||
execute fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/tlscacerts/* ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/signcerts/* ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
|
||||
|
|
@ -200,9 +169,7 @@ function createOrg2 {
|
|||
echo
|
||||
echo "## Generate the user msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/config.yaml
|
||||
|
||||
|
|
@ -211,28 +178,21 @@ function createOrg2 {
|
|||
echo
|
||||
echo "## Generate the org admin msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml
|
||||
|
||||
}
|
||||
|
||||
function createOrderer {
|
||||
|
||||
echo
|
||||
echo "Enroll the CA admin"
|
||||
echo
|
||||
mkdir -p organizations/ordererOrganizations/example.com
|
||||
|
||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/fabric-ca-client-config.yaml
|
||||
# rm -rf $FABRIC_CA_CLIENT_HOME/msp
|
||||
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://admin:adminpw@localhost:9054 --caname ca-orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://admin:adminpw@localhost:9054 --caname ca-orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
echo 'NodeOUs:
|
||||
Enable: true
|
||||
|
|
@ -253,37 +213,28 @@ function createOrderer {
|
|||
echo
|
||||
echo "Register orderer"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
echo
|
||||
echo "Register the orderer admin"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
mkdir -p organizations/ordererOrganizations/example.com/orderers
|
||||
mkdir -p organizations/ordererOrganizations/example.com/orderers/example.com
|
||||
|
||||
mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com
|
||||
|
||||
echo
|
||||
echo "## Generate the orderer msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml
|
||||
|
||||
echo
|
||||
echo "## Generate the orderer-tls certificates"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/tlscacerts/* ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
|
||||
cp ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/signcerts/* ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
|
||||
|
|
@ -301,11 +252,7 @@ function createOrderer {
|
|||
echo
|
||||
echo "## Generate the admin msp"
|
||||
echo
|
||||
set -x
|
||||
fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
set +x
|
||||
execute fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||
|
||||
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,16 +13,19 @@ VERBOSE="$4"
|
|||
# import utils
|
||||
. scripts/envVar.sh
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
if [ ! -d "channel-artifacts" ]; then
|
||||
mkdir channel-artifacts
|
||||
fi
|
||||
|
||||
createChannelTx() {
|
||||
|
||||
set -x
|
||||
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/${CHANNEL_NAME}.tx -channelID $CHANNEL_NAME
|
||||
execute configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/${CHANNEL_NAME}.tx -channelID $CHANNEL_NAME
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate channel configuration transaction..."
|
||||
exit 1
|
||||
|
|
@ -32,19 +35,15 @@ createChannelTx() {
|
|||
}
|
||||
|
||||
createAncorPeerTx() {
|
||||
|
||||
for orgmsp in Org1MSP Org2MSP; do
|
||||
|
||||
echo "####### Generating anchor peer update transaction for ${orgmsp} ##########"
|
||||
set -x
|
||||
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/${orgmsp}anchors.tx -channelID $CHANNEL_NAME -asOrg ${orgmsp}
|
||||
res=$?
|
||||
set +x
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate anchor peer update transaction for ${orgmsp}..."
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "####### Generating anchor peer update transaction for ${orgmsp} ##########"
|
||||
execute configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/${orgmsp}anchors.tx -channelID $CHANNEL_NAME -asOrg ${orgmsp}
|
||||
res=$?
|
||||
if [ $res -ne 0 ]; then
|
||||
echo "Failed to generate anchor peer update transaction for ${orgmsp}..."
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -55,10 +54,8 @@ createChannel() {
|
|||
local COUNTER=1
|
||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||
sleep $DELAY
|
||||
set -x
|
||||
peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls --cafile $ORDERER_CA >&log.txt
|
||||
execute peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls --cafile $ORDERER_CA >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
let rc=$res
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
done
|
||||
|
|
@ -78,10 +75,8 @@ joinChannel() {
|
|||
## Sometimes Join takes time, hence retry
|
||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||
sleep $DELAY
|
||||
set -x
|
||||
peer channel join -b ./channel-artifacts/$CHANNEL_NAME.block >&log.txt
|
||||
execute peer channel join -b ./channel-artifacts/$CHANNEL_NAME.block >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
let rc=$res
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
done
|
||||
|
|
@ -98,10 +93,8 @@ updateAnchorPeers() {
|
|||
## Sometimes Join takes time, hence retry
|
||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||
sleep $DELAY
|
||||
set -x
|
||||
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile $ORDERER_CA >&log.txt
|
||||
execute peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile $ORDERER_CA >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
let rc=$res
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
done
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
|||
|
||||
FABRIC_CFG_PATH=$PWD/../config/
|
||||
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
# User has not provided a path, therefore the CC_NAME must
|
||||
# be the short name of a known chaincode sample
|
||||
|
|
@ -147,10 +151,8 @@ fi
|
|||
packageChaincode() {
|
||||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
|
||||
execute peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode packaging on peer0.org${ORG} has failed"
|
||||
echo "===================== Chaincode is packaged on peer0.org${ORG} ===================== "
|
||||
|
|
@ -161,10 +163,8 @@ packageChaincode() {
|
|||
installChaincode() {
|
||||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
|
||||
execute peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode installation on peer0.org${ORG} has failed"
|
||||
echo "===================== Chaincode is installed on peer0.org${ORG} ===================== "
|
||||
|
|
@ -175,10 +175,8 @@ installChaincode() {
|
|||
queryInstalled() {
|
||||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode queryinstalled >&log.txt
|
||||
execute peer lifecycle chaincode queryinstalled >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
PACKAGE_ID=$(sed -n "/${CC_NAME}_${CC_VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)
|
||||
verifyResult $res "Query installed on peer0.org${ORG} has failed"
|
||||
|
|
@ -190,9 +188,7 @@ queryInstalled() {
|
|||
approveForMyOrg() {
|
||||
ORG=$1
|
||||
setGlobals $ORG
|
||||
set -x
|
||||
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --package-id ${PACKAGE_ID} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
|
||||
set +x
|
||||
execute peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --package-id ${PACKAGE_ID} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
||||
echo "===================== Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||
|
|
@ -212,10 +208,8 @@ checkCommitReadiness() {
|
|||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
|
||||
sleep $DELAY
|
||||
echo "Attempting to check the commit readiness of the chaincode definition on peer0.org${ORG}, Retry after $DELAY seconds."
|
||||
set -x
|
||||
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json >&log.txt
|
||||
execute peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
let rc=0
|
||||
for var in "$@"; do
|
||||
grep "$var" log.txt &>/dev/null || let rc=1
|
||||
|
|
@ -242,10 +236,8 @@ commitChaincodeDefinition() {
|
|||
# while 'peer chaincode' command can get the orderer endpoint from the
|
||||
# peer (if join was successful), let's supply it directly as we know
|
||||
# it using the "-o" option
|
||||
set -x
|
||||
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} $PEER_CONN_PARMS --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
|
||||
execute peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name ${CC_NAME} $PEER_CONN_PARMS --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
||||
echo "===================== Chaincode definition committed on channel '$CHANNEL_NAME' ===================== "
|
||||
|
|
@ -265,10 +257,8 @@ queryCommitted() {
|
|||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
|
||||
sleep $DELAY
|
||||
echo "Attempting to Query committed status on peer0.org${ORG}, Retry after $DELAY seconds."
|
||||
set -x
|
||||
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME} >&log.txt
|
||||
execute peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME} >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: '$CC_VERSION', Sequence: [0-9], Endorsement Plugin: escc, Validation Plugin: vscc')
|
||||
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
|
|
@ -294,12 +284,10 @@ chaincodeInvokeInit() {
|
|||
# while 'peer chaincode' command can get the orderer endpoint from the
|
||||
# peer (if join was successful), let's supply it directly as we know
|
||||
# it using the "-o" option
|
||||
set -x
|
||||
fcn_call='{"function":"'${CC_INIT_FCN}'","Args":[]}'
|
||||
echo invoke fcn call:${fcn_call}
|
||||
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA -C $CHANNEL_NAME -n ${CC_NAME} $PEER_CONN_PARMS --isInit -c ${fcn_call} >&log.txt
|
||||
execute peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile $ORDERER_CA -C $CHANNEL_NAME -n ${CC_NAME} $PEER_CONN_PARMS --isInit -c ${fcn_call} >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
verifyResult $res "Invoke execution on $PEERS failed "
|
||||
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "
|
||||
|
|
@ -317,10 +305,8 @@ chaincodeQuery() {
|
|||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do
|
||||
sleep $DELAY
|
||||
echo "Attempting to Query peer0.org${ORG}, Retry after $DELAY seconds."
|
||||
set -x
|
||||
peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllCars"]}' >&log.txt
|
||||
execute peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllCars"]}' >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
let rc=$res
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
done
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ MAX_RETRY=5
|
|||
# import environment variables
|
||||
. scripts/org3-scripts/envVarCLI.sh
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
# fetchChannelConfig <channel_id> <output_json>
|
||||
# Writes the current channel config for a given channel to a JSON file
|
||||
|
|
@ -38,14 +43,10 @@ fetchChannelConfig() {
|
|||
setGlobals $ORG
|
||||
|
||||
echo "Fetching the most recent configuration block for the channel"
|
||||
set -x
|
||||
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
|
||||
set +x
|
||||
execute peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
|
||||
|
||||
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
||||
set -x
|
||||
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}"
|
||||
set +x
|
||||
execute configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}"
|
||||
}
|
||||
|
||||
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
||||
|
|
@ -57,14 +58,13 @@ createConfigUpdate() {
|
|||
MODIFIED=$3
|
||||
OUTPUT=$4
|
||||
|
||||
set -x
|
||||
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb
|
||||
configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb
|
||||
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb
|
||||
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json
|
||||
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
|
||||
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}"
|
||||
set +x
|
||||
execute configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb
|
||||
execute configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb
|
||||
execute configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb
|
||||
execute configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json
|
||||
# TODO
|
||||
execute echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
|
||||
execute configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}"
|
||||
}
|
||||
|
||||
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
||||
|
|
@ -73,9 +73,7 @@ signConfigtxAsPeerOrg() {
|
|||
PEERORG=$1
|
||||
TX=$2
|
||||
setGlobals $PEERORG
|
||||
set -x
|
||||
peer channel signconfigtx -f "${TX}"
|
||||
set +x
|
||||
execute peer channel signconfigtx -f "${TX}"
|
||||
}
|
||||
|
||||
echo
|
||||
|
|
@ -86,9 +84,7 @@ echo
|
|||
fetchChannelConfig 1 ${CHANNEL_NAME} config.json
|
||||
|
||||
# Modify the configuration to append the new org
|
||||
set -x
|
||||
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json
|
||||
set +x
|
||||
execute jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json
|
||||
|
||||
# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb
|
||||
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
|
||||
|
|
@ -105,12 +101,8 @@ echo
|
|||
echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= "
|
||||
echo
|
||||
setGlobals 2
|
||||
set -x
|
||||
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${ORDERER_CA}
|
||||
set +x
|
||||
execute peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${ORDERER_CA}
|
||||
|
||||
echo
|
||||
echo "========= Config transaction to add org3 to network submitted! =========== "
|
||||
echo
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -28,15 +28,19 @@ MAX_RETRY=5
|
|||
# import environment variables
|
||||
. scripts/org3-scripts/envVarCLI.sh
|
||||
|
||||
# execute - Prints and executes the command
|
||||
function execute() {
|
||||
echo -e "\033[0;32mCommand\033[0m: ${*}"
|
||||
"${@}"
|
||||
}
|
||||
|
||||
## Sometimes Join takes time hence RETRY at least 5 times
|
||||
joinChannelWithRetry() {
|
||||
ORG=$1
|
||||
setGlobals $ORG
|
||||
|
||||
set -x
|
||||
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
||||
execute peer channel join -b $CHANNEL_NAME.block >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
|
||||
COUNTER=$(expr $COUNTER + 1)
|
||||
|
|
@ -51,10 +55,8 @@ joinChannelWithRetry() {
|
|||
|
||||
|
||||
echo "Fetching channel config block from orderer..."
|
||||
set -x
|
||||
peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
|
||||
execute peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
|
||||
res=$?
|
||||
set +x
|
||||
cat log.txt
|
||||
verifyResult $res "Fetching config block from orderer has Failed"
|
||||
|
||||
|
|
@ -64,5 +66,3 @@ echo "===================== peer0.org3 joined channel '$CHANNEL_NAME' ==========
|
|||
echo
|
||||
echo "========= Finished adding Org3 to your test network! ========= "
|
||||
echo
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue