1,基础目录网盘地址

链接:https://share.weiyun.com/5jn0Kzf 密码:tcvgxn

为减少体积,blockchain-explorer node_modules 全部删除,需要npm install

cd $BLOCKCHAIN_EXPLORER/
npm install
cd $BLOCKCHAIN_EXPLORER/client
npm install
cd $BLOCKCHAIN_EXPLORER/
./start.sh

链码实例化指定背书策略是全员背书
第三个组织加入前的策略

"AND ('airwh.member','njairport.member')"

第三个组织加入后的策略

"AND ('njairport.member','airwh.member','tna.member')"

2,自动化脚本


testret(){

   if [ $1 -ne 0 ]; then
      exit 1;
   fi
   printf  "[\033[36m %s \033[0m]\n"   "OK" 

}

unsetenv(){
   unset FABRIC_CFG_PATH
   unset CORE_PEER_LOCALMSPID
   unset CORE_PEER_ADDRESS
   unset CORE_PEER_MSPCONFIGPATH
}


printf "\n"

TEST_HOME=$(cd $(dirname $0); pwd)
ROOT_MSP=$TEST_HOME/certs/root
mkdir -p $ROOT_MSP
FABRIC_CA=http://admin:admin@orderer.cares.com:5054





printf  '%-70s'   'clear certs'

rm -fr $TEST_HOME/certs/*
testret $?


if [ -d "$TEST_HOME/logs" ];then
    rm -fr $TEST_HOME/logs/*
else
    mkdir -p $TEST_HOME/logs    
fi

if [ -d "$TEST_HOME/tmp" ];then
   rm -fr $TEST_HOME/tmp/*
else
   mkdir -p $TEST_HOME/tmp
fi



printf  '%-70s'   'start FABRIC-CA'
$TEST_HOME/server/start
testret $?


reqcerts(){
    name=$1
    type=$2
    CERT_DIR=ordererOrgs
    NODE_DIR=orderers

    if [ "$type" = "peer" ]; then
        CERT_DIR="peerOrgs"
        NODE_DIR="peers"
    fi    


    printf "\t%-62s" "get cacert of $name"
    mkdir -p $TEST_HOME/certs/$CERT_DIR/$name/msp/
    fabric-ca-client getcacert -M $TEST_HOME/certs/$CERT_DIR/$name/msp/ -H $TEST_HOME/certs/root/ -u $FABRIC_CA > /dev/null 2>&1
    testret $?


    printf  '\t%-62s'   "register orgAdmin of  $name"
    fabric-ca-client register --id.name Admin@$name.cares.com \
                              --id.secret 111111 \
                              --id.type client \
                              --id.affiliation com.cares.$name \
                              --id.attrs '"hf.Registrar.Roles=client,orderer,peer,user","hf.Registrar.DelegateRoles=client,orderer,peer,user",hf.Registrar.Attributes=*,hf.GenCRL=true,hf.Revoker=true,hf.AffiliationMgr=true,role=admin:ecert' \
-H $TEST_HOME/certs/root/ \
-u $FABRIC_CA > /dev/null 2>&1
    testret $?

    sleep 1s   
    printf '\t%-62s'   "enroll orgAdmin of  $name"
    fabric-ca-client enroll -u http://Admin@$name.cares.com:111111@localhost:5054  -H $TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com -u $FABRIC_CA > /dev/null 2>&1
    testret $?

    printf '\t%-62s'   "copy admin certs of  $name"
    mkdir -p $TEST_HOME/certs/$CERT_DIR/$name/msp/admincerts
    ADMINCERTFROM=$TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com/msp/signcerts/*
    ADMINCERTTO=$TEST_HOME/certs/$CERT_DIR/$name/msp/admincerts/
    cp $ADMINCERTFROM $ADMINCERTTO
    testret $?

    mkdir -p $TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com/msp/admincerts
    cp $ADMINCERTFROM $TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com/msp/admincerts

    printf '\t%-62s\n'   "register subAccount using admin of $2"

    accounts=$3
    if [ ! -n "$accounts" ];then
         accounts=1
    fi


    for((i=0;i<$accounts;i++));
    do
        fabric-ca-client register -u http://localhost:5054 --id.name $type$i@$name.cares.com --id.secret 111111 --id.type $type \
--id.affiliation com.cares.$name --id.attrs "role=$type:ecert"   -H $TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com -u $FABRIC_CA > /dev/null 2>&1
        fabric-ca-client enroll -u http://orderer1@orderer.cares.com:111111@localhost:5054  -H $TEST_HOME/certs/$CERT_DIR/$name/$NODE_DIR/$type$i@$name.cares.com -u $FABRIC_CA > /dev/null 2>&1
        mkdir -p $TEST_HOME/certs/$CERT_DIR/$name/$NODE_DIR/$type$i@$name.cares.com/msp/admincerts
        cp $TEST_HOME/certs/$CERT_DIR/$name/users/Admin@$name.cares.com/msp/signcerts/cert.pem  $TEST_HOME/certs/$CERT_DIR/$name/$NODE_DIR/$type$i@$name.cares.com/msp/admincerts
    done


}



delaffiliation(){
         fabric-ca-client affiliation list --affiliation $1   -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1
     if [ $? -eq 0 ];then
       printf  '\t%-62s'   " delete org $1"
       fabric-ca-client affiliation remove $1 --force  -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1 
       testret $?
     fi
}




printf  '%-70s'   ' wait FABRIC-CA process to be startup'
LISTENSTATUS=1

while [ $LISTENSTATUS -ne 0 ]
do
   sleep 0.1s
   netstat -an|grep 5054|grep LISTEN > /dev/null 2>&1
   LISTENSTATUS=$?
done

testret 0

mkdir -p $ROOT_MSP
printf  '%-70s'   'register  MSP ROOT'
fabric-ca-client enroll  -u $FABRIC_CA -H $ROOT_MSP  > /dev/null 2>&1
testret $?


printf  '%-70s\n'   'delete orgs affiliations'
delaffiliation com



printf '%-70s' "WORK DIR:$TEST_HOME"
testret 0


PEER_PIDS=$(ps -ef|grep 'peer node start'|grep -v grep|awk '{print $2}')

if [ -n "$PEER_PIDS" ]; then
  printf  '%-70s'   'stop peers processes'
  kill -9 $PEER_PIDS
  testret $?
fi
sleep 1s


ORDER_PID=$(ps -ef|grep 'orderer start'|grep -v grep|awk '{print $2}')

if [ -n "$ORDER_PID" ]; then
  printf  '%-70s'   'stop orderer process'
  kill -9 $ORDER_PID
  testret $?
fi
sleep 1s


EXPLORE_PID=$(ps -ef|grep 'node main.js name - hyperledger-explorer'|grep -v grep|awk '{print $2}')

if [ -n "$EXPLORE_PID" ]; then
  printf  '%-70s'   'stop FABRIC EXPPLORER'
  cd $TEST_HOME/blockchain-explorer
  nohup ./stop.sh > /dev/null 2>&1 &
  testret $?
fi
sleep 2s

printf  '%-70s'   'clear data files'
rm -rf rm -fr $TEST_HOME/test/data/*
testret $?


IMG_IDS=$(docker ps -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $1}')
if [ -n "$IMG_IDS" ]; then
    printf  '%-70s'   'stop chaincode containers'
    docker stop  $(docker ps -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $1}') > /dev/null 2>&1    
    testret $?
fi




IMG_IDS=$(docker ps -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $1}')
if [ -n "$IMG_IDS" ]; then
    printf  '%-70s'   'remove chaincode containers'
    docker rm  $(docker ps -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $1}') > /dev/null 2>&1
    testret $?

fi



IMG_IDS=$(docker images -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $3}')
if [ -n "$IMG_IDS" ]; then
    printf  '%-70s'   'remove chaincode images'
    docker rmi  $(docker images -a|grep -E 'dev-peer|devairwh-peer'|awk '{print $3}') > /dev/null 2>&1    
    testret $?
fi


mkdir -p $ROOT_MSP

printf  '%-70s\n'   'register org affiliations'
printf  '\t%-62s'   'register affiliations com'
fabric-ca-client affiliation add com -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1
testret $?

printf  '%-70s\n'   'register org affiliations'
printf  '\t%-62s'   'register affiliations com.cares'
fabric-ca-client affiliation add com.cares -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1
testret $?

printf  '%-70s\n'   'register org affiliations'
printf  '\t%-62s'   'register affiliations com.cares.orderer'
fabric-ca-client affiliation add com.cares.orderer -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1
testret $?

printf  '\t%-62s'   'register affiliations com.cares.nkg'
fabric-ca-client affiliation add com.cares.nkg -H $ROOT_MSP -u $FABRIC_CA > /dev/null 2>&1
testret $?

printf  '\t%-62s'   'register affiliations com.cares.weh'
fabric-ca-client affiliation add com.cares.weh -H $ROOT_MSP  -u $FABRIC_CA > /dev/null 2>&1
testret $?

printf  '\t%-62s'   'register affiliations com.cares.tna'
fabric-ca-client affiliation add com.cares.tna -H $ROOT_MSP  -u $FABRIC_CA > /dev/null 2>&1
testret $?

mkdir -p $TEST_HOME/certs/{peerOrgs,ordererOrgs}


printf '%-70s\n'   "get cert of orderer"
reqcerts orderer  orderer
printf '%-70s\n'   "get cert of nkg"
reqcerts nkg  peer
printf '%-70s\n'   "get cert of weh"
reqcerts weh  peer
printf '%-70s\n'   "get cert of tna"
reqcerts tna  peer


if [ "$1" = "down" ];then
   exit 0
fi


printf  '%-70s'  '1,create system genesis'

unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/cfg
configtxgen  -profile SampleSingleMSPSolo -outputBlock $TEST_HOME/test/data/orderer.genesis.block -channelID sys-security > /dev/null 2>&1
testret $?


printf  '%-70s'  '2,create channel genesis'
configtxgen  -profile SampleSingleMSPSoloChannel -outputCreateChannelTx $TEST_HOME/test/data/securityCheck.channel.tx -channelID securitycheck > /dev/null 2>&1
testret $?



printf  '%-70s'  '3,create anchor njairport'
configtxgen  -profile SampleSingleMSPSoloChannel -outputAnchorPeersUpdate $TEST_HOME/test/data/njairportMSPanchors.tx -channelID securitycheck -asOrg njairport > /dev/null 2>&1
testret $?


printf  '%-70s'  '4,create anchor airwh'
configtxgen  -profile SampleSingleMSPSoloChannel -outputAnchorPeersUpdate $TEST_HOME/test/data/airwhMSPanchors.tx -channelID securitycheck -asOrg airwh > /dev/null 2>&1
testret $?

printf  '%-70s'  '5,start orderer'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/order
nohup orderer start > $TEST_HOME/logs/orderer.log 2>&1 &
testret $?



printf  '%-70s'  '6,start peer0 njairport'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg/
nohup peer node start > $TEST_HOME/logs/njairport-peer0.log 2>&1 &
testret $?



printf  '%-70s'  '7,start peer0 airwh'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
nohup peer node start > $TEST_HOME/logs/airwh-peer0.log 2>&1 &
testret $?

printf  '%-70s\n\t%-62s'  '8,create ledger channel ' 'wait orderer process'

LISTENSTATUS=1

while [ $LISTENSTATUS -ne 0 ]
do
   sleep 1s
   netstat -an|grep 7050|grep LISTEN > /dev/null 2>&1
   LISTENSTATUS=$?
done
unsetenv

export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer channel create -o orderer.cares.com:7050 -c securitycheck -f $TEST_HOME/test/data/securityCheck.channel.tx  --outputBlock $TEST_HOME/test/data/securitycheck.block > /dev/null 2>&1
testret $?

printf  '%-70s'  '9,nkg peer0 join channel'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer channel join -b $TEST_HOME/test/data/securitycheck.block > /dev/null 2>&1
testret $?


printf  '%-70s'  '10,weh peer0 join channel'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer channel join -b $TEST_HOME/test/data/securitycheck.block > /dev/null 2>&1
testret $?


printf  '%-70s'  '11,update anchor njairport'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer channel update -o orderer.cares.com:7050 -c securitycheck -f $TEST_HOME/test/data/njairportMSPanchors.tx > /dev/null 2>&1
testret $?


printf  '%-70s'  '12,update anchor airwh'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer channel update -o orderer.cares.com:7050 -c securitycheck -f $TEST_HOME/test/data/airwhMSPanchors.tx > /dev/null 2>&1
testret $?


## java 链码部署需要下载依赖,编译较慢 这里用go链码快速演示 go链码依赖于 $GOPATH
printf  '%-70s'  '13,install chaincode peer0 njairport'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer chaincode install  -n test -v 1.0 -p  chaincode_example02 -l golang > /dev/null 2>&1
testret $?


printf  '%-70s'  '14,install chaincode peer0 airwh'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer chaincode install  -n test -v 1.0 -p  chaincode_example02 -l golang > /dev/null 2>&1
testret $?



printf  '%-70s'  '15, instantiate chaincode peer0 njairport a=200,b=200'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer chaincode instantiate -o orderer.cares.com:7050 -C securitycheck -n test -l golang -v 1.0 -c '{"Args":["init","a","200","b","200"]}' -P "AND ('airwh.member','njairport.member')" > /dev/null 2>&1
testret $?

printf  '%-70s\n'  '16, peer0 njairport a transfer 5 to b' 
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
IMGSTATUS=1
printf  '\t%-62s'  'wait chaincode container up'
while [ $IMGSTATUS -ne 0 ]
do
   ps -ef|grep 'chaincode -peer.address='|grep -v grep  > /dev/null 2>&1
   IMGSTATUS=$?
done

sleep 5s

peer chaincode invoke -o orderer.cares.com:7050  -C securitycheck -n test -c '{"Args":["invoke","a","b","5"]}' --peerAddresses peer0.nkg.cares.com:7051 --peerAddresses peer0.weh.cares.com:7053 --waitForEvent > /dev/null 2>&1
testret $?


printf  '%-70s'  '17,peer0 njairport query value of a'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/nkg
sleep 3s
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}'



printf  '%-70s'  '18,peer0 njairport query value of b'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'


printf  '%-70s'  '19,peer0 airwh query value of a'
unsetenv
export FABRIC_CFG_PATH=$TEST_HOME/config/peers/weh
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}' 


printf  '%-70s'  '20,peer0 airwh query value of b'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'


docker ps|grep 'hyperledger/explorer-db' > /dev/null
if [ $? -eq 0 ]; then

    docker exec -it -u postgres  postgresql dropdb fabricexplorer > /dev/null
    sleep 1s
    docker exec -it -u postgres  postgresql /opt/createdb.sh > /dev/null
    sleep 1s
    rm -fr $TEST_HOME/blockchain-explorer/wallet/*
    rm -fr $TEST_HOME/blockchain-explorer/logs/*
    PRE_KEY=`cat $TEST_HOME/blockchain-explorer/app/platform/fabric/connection-profile/first-network.json|grep -o 'keystore/.*sk'|awk -F / '{print $2}'`
    if [ -n "$PRE_KEY" ]; then
        CUR_KEY=`ls $TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp/keystore/`
        sed -i "s#$PRE_KEY#$CUR_KEY#g"  $TEST_HOME/blockchain-explorer/app/platform/fabric/connection-profile/first-network.json
        cd $TEST_HOME/blockchain-explorer
        nohup ./start.sh > /dev/null 2>&1 &

    fi

fi


printf  '%-70s\n'  'Hyperledger Fabric CA 简易网络 搭建成功'

if [ "$1" != "add" ];then
  exit 0
fi

printf  '%-70s\n'  '动态组织加入 济南机场'
export FABRIC_LOGGING_SPEC=ERROR
mkdir -p $TEST_HOME/tmp
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/cfg/tna
printf  '%-70s' 'Generating TNA config material'
configtxgen -printOrg tna > $TEST_HOME/tmp/tna.json
testret $?

printf  '%-70s' 'Fetching the most recent configuration block for the channel'
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer channel fetch config $TEST_HOME/tmp/config_block.pb -o orderer.cares.com:7050 -c securitycheck
testret $?

printf '%-70s' 'Decoding config block to JSON'
configtxlator proto_decode --input $TEST_HOME/tmp/config_block.pb --type common.Block | jq .data.data[0].payload.data.config > $TEST_HOME/tmp/config.json
testret $?

printf '%-70s' 'Modify the configuration to append the new org'
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"tna":.[1]}}}}}' $TEST_HOME/tmp/config.json $TEST_HOME/tmp/tna.json > $TEST_HOME/tmp/modified_config.json
testret $?

printf '%-70s' 'write it as a transaction'
configtxlator proto_encode --input $TEST_HOME/tmp/config.json  --type common.Config >  $TEST_HOME/tmp/original_config.pb 

configtxlator proto_encode --input $TEST_HOME/tmp/modified_config.json --type common.Config > $TEST_HOME/tmp/modified_config.pb

configtxlator compute_update --channel_id securitycheck --original $TEST_HOME/tmp/original_config.pb --updated $TEST_HOME/tmp/modified_config.pb > $TEST_HOME/tmp/config_update.pb

configtxlator proto_decode --input $TEST_HOME/tmp/config_update.pb --type common.ConfigUpdate > $TEST_HOME/tmp/config_update.json

echo '{"payload":{"header":{"channel_header":{"channel_id":"'securitycheck'", "type":2}},"data":{"config_update":'$(cat $TEST_HOME/tmp/config_update.json)'}}}' | jq . > $TEST_HOME/tmp/config_update_in_envelope.json
configtxlator proto_encode --input $TEST_HOME/tmp/config_update_in_envelope.json --type common.Envelope > $TEST_HOME/tmp/org3_update_in_envelope.pb

testret $?



printf '%-70s' 'Signing config transaction'
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer channel signconfigtx -f $TEST_HOME/tmp/org3_update_in_envelope.pb
testret $?

printf '%-70s' 'Submit config  transaction'
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer channel update -f $TEST_HOME/tmp/org3_update_in_envelope.pb -c securitycheck -o orderer.cares.com:7050
testret $?


printf '%-70s' 'startup peer0 of tna'
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
nohup peer node start >  $TEST_HOME/logs/peer0.tna.log 2>&1 &
testret $?


printf '%-70s\n'  'Have Org3 peers join network'
printf '\t%-62s' "Fetching channel config block from orderer..."
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/tna/users/Admin@tna.cares.com/msp
peer channel fetch 0 $TEST_HOME/tmp/securitycheck.block -o orderer.cares.com:7050 -c securitycheck  > /dev/null 2>&1
testret $?


export FABRIC_LOGGING_SPEC=ERROR
printf '\t%-62s' "JOIN channel..."
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/tna/users/Admin@tna.cares.com/msp
sleep 5s
peer channel join -b $TEST_HOME/tmp/securitycheck.block > /dev/null 2>&1
testret $?


printf '\t%-62s' "tna install chaincode test 2.0"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/tna/users/Admin@tna.cares.com/msp
peer chaincode install -n test -v 2.0  -l golang -p chaincode_example02 > /dev/null 2>&1
testret $?


printf '%-70s\n' "Upgrade chaincode to have Org3 peers on the network"

printf '\t%-62s' "nkg install chaincode test 2.0"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer chaincode install -n test -v 2.0  -l golang -p chaincode_example02 > /dev/null 2>&1
testret $?


printf '\t%-62s' "weh install chaincode test 2.0"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/weh
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/weh/users/Admin@weh.cares.com/msp
peer chaincode install -n test -v 2.0  -l golang -p chaincode_example02 > /dev/null 2>&1
testret $?


printf '\t%-62s' "nkg upgrade chaincode test 2.0, initial a=90,b=210"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/nkg
export CORE_PEER_MSPCONFIGPATH=$TEST_HOME/certs/peerOrgs/nkg/users/Admin@nkg.cares.com/msp
peer chaincode upgrade -o orderer.cares.com:7050 -C securitycheck -n test -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "AND ('njairport.member','airwh.member','tna.member')" > /dev/null
testret $?

sleep 3s

printf '%-70s\n' "test chaincode after tna join network"


printf '\t%-62s\n' "tna query a b value"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'
sleep 2s


printf '\t%-62s' "tna do transaction a transfer 10 to b"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
peer chaincode invoke -o orderer.cares.com:7050 -C securitycheck -n test  -c '{"Args":["invoke","a","b","10"]}' --peerAddresses peer0.nkg.cares.com:7051 --peerAddresses peer0.weh.cares.com:7053 --peerAddresses peer0.tna.cares.com:8051 --waitForEvent > /dev/null 2>&1
testret $?
sleep 2s


printf '\t%-62s\n' "tna query a b value"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/tna
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'
sleep 2s

printf '\t%-62s\n' "nkg query a b value"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/nkg
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'
sleep 2s


printf '\t%-62s\n' "weh query a b value"
unsetenv
export FABRIC_CFG_PATH=/home/wangcj/workspace/ca_solo/config/peers/weh
peer chaincode query -C securitycheck -n test -c '{"Args":["query","a"]}'
peer chaincode query -C securitycheck -n test -c '{"Args":["query","b"]}'


printf '%-70s\n' "济南机场成功加入"

3,区块链浏览器查看背书交易详情

3.1 第三个组织加入前

upload successful

3.2 第三个组织加入后

upload successful



区块链      fabric endorsement 动态组织加入

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!