一、修改链码,上传
二、打包链码
1、设置组织1环境变量
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
# Environment variables for Org1
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/peers/peer0.org1.sdmk.com.cn/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/users/Admin@org1.sdmk.com.cn/msp
export CORE_PEER_ADDRESS=localhost:7051
2、重新打包链码
peer lifecycle chaincode package sdmkmeterchannel.tar.gz --path ./meter-chaincode/chaincode-go/ --lang golang --label sdmkmeterchannel_2.0?
#安装
peer lifecycle chaincode install sdmkmeterchannel.tar.gz
#查询已安装链码
peer lifecycle chaincode queryinstalled
?组织2也安装,先设置组织2环境变量
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.sdmk.com.cn/peers/peer0.org2.sdmk.com.cn/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.sdmk.com.cn/users/Admin@org2.sdmk.com.cn/msp
export CORE_PEER_ADDRESS=localhost:9051
peer lifecycle chaincode install sdmkmeterchannel.tar.gz
peer lifecycle chaincode queryinstalled
设置PACKAGE_ID
export PACKAGE_ID=s
?3、设置所需要的环境变量
export CORE_PEER_TLS_ENABLED=true
export ORDERER_CA=${PWD}/organizations/ordererOrganizations/sdmk.com.cn/orderers/orderer.sdmk.com.cn/msp/tlscacerts/tlsca.sdmk.com.cn-cert.pem
export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/peers/peer0.org1.sdmk.com.cn/tls/ca.crt
export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.sdmk.com.cn/peers/peer0.org2.sdmk.com.cn/tls/ca.crt
export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/sdmk.com.cn/orderers/orderer.sdmk.com.cn/tls/server.crt
export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/sdmk.com.cn/orderers/orderer.sdmk.com.cn/tls/server.key
export CHANNEL_NAME="sdmkmeterchannel"
export CC_NAME=sdmkmeterbasic
export CC_SRC_PATH=./meter-chaincode/chaincode-go/
export CC_SRC_LANGUAGE=go
export CC_VERSION="2.0"
export CC_SEQUENCE="2"
export CC_INIT_FCN=""
export CC_END_POLICY=""
export CC_COLL_CONFIG=""
export DELAY="3"
export MAX_RETRY="5"
export VERBOSE="false"
export INIT_REQUIRED=""
export CC_RUNTIME_LANGUAGE=golang
4、重新同意链码定义
目前还是组织机构2环境变量
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.sdmk.com.cn --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}
##查询当前链码定义已同意的组织
peer lifecycle chaincode checkcommitreadiness --name ${CC_NAME} --channelID $CHANNEL_NAME --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json
?
?切换组织1环境变量
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
# Environment variables for Org1
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/peers/peer0.org1.sdmk.com.cn/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/users/Admin@org1.sdmk.com.cn/msp
export CORE_PEER_ADDRESS=localhost:7051
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.sdmk.com.cn --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}
##查询当前链码定义已同意的组织
peer lifecycle chaincode checkcommitreadiness --name ${CC_NAME} --channelID $CHANNEL_NAME --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json
?结果显示,组织1,组织2都已经显示
5、重新提交链码定义
export PEER_CONN_PARMS=(--peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.sdmk.com.cn/peers/peer0.org1.sdmk.com.cn/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.sdmk.com.cn/peers/peer0.org2.sdmk.com.cn/tls/ca.crt)
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.sdmk.com.cn --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}
?6、查询提交定义的结果
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME}
?恭喜你,链码升级成功
|