Add scripts for cc operations
parent
3479f414d9
commit
65f7a733f9
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
# Invoke a chaincode
|
||||
# Usage: ./script mspId channel peerAddr ccName mspPath=${PWD}/msp-mspId
|
||||
|
||||
# Entry function
|
||||
main() {
|
||||
if [ $# -lt 4 ]; then
|
||||
echo "Not enough argument supplied"
|
||||
echo "$(basename $0) mspId channel peerAddr ccName mspPath=${PWD}/msp-mspId"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local mspId=$1
|
||||
local channel=$2
|
||||
local peerAddr=$3
|
||||
local ccName=$4
|
||||
local mspPath=${5:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id}
|
||||
|
||||
export FABRIC_LOGGING_SPEC="debug"
|
||||
export CORE_PEER_ADDRESS="${peerAddr}"
|
||||
export CORE_PEER_LOCALMSPID=${mspId}
|
||||
export CORE_PEER_MSPCONFIGPATH=${mspPath}
|
||||
export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert
|
||||
export CORE_PEER_TLS_ENABLED=true
|
||||
|
||||
discover \
|
||||
--peerTLSCA "${CORE_PEER_TLS_ROOTCERT_FILE}" \
|
||||
--userKey ${mspPath}/keystore/${mspId}-key \
|
||||
--userCert ${mspPath}/signcerts/${mspId}-cert.pem \
|
||||
--MSP "${mspId}" \
|
||||
endorsers \
|
||||
--channel "${channel}" \
|
||||
--chaincode "${ccName}" \
|
||||
--server "${peerAddr}"
|
||||
#--tlsCert tls/client.crt \
|
||||
#--tlsKey tls/client.key \
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
# Invoke a chaincode
|
||||
# Usage: ./script mspId channel ordererAddr peerAddr ccName mspPath=${PWD}/msp-mspId
|
||||
|
||||
# Entry function
|
||||
main() {
|
||||
if [ $# -lt 5 ]; then
|
||||
echo "Not enough argument supplied"
|
||||
echo "$(basename $0) mspId channel ordererAddr peerAddr ccName mspPath=${PWD}/msp-mspId"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local mspId=$1
|
||||
local channel=$2
|
||||
local ordererAddr=$3
|
||||
local peerAddr=$4
|
||||
local ccName=$5
|
||||
local mspPath=${6:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id}
|
||||
|
||||
export FABRIC_LOGGING_SPEC="debug"
|
||||
export CORE_PEER_ADDRESS="${peerAddr}"
|
||||
export CORE_PEER_LOCALMSPID=${mspId}
|
||||
export CORE_PEER_MSPCONFIGPATH=${mspPath}
|
||||
export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert
|
||||
export CORE_PEER_TLS_ENABLED=true
|
||||
|
||||
peer chaincode invoke \
|
||||
--connTimeout="30s" \
|
||||
-o "${ordererAddr}" \
|
||||
-C "${channel}" \
|
||||
-n "${ccName}" \
|
||||
--peerAddresses "${peerAddr}" \
|
||||
--tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}" \
|
||||
-c '{"Args":["invoke","a","b","10"]}' \
|
||||
--tls \
|
||||
--cafile "${CORE_PEER_TLS_ROOTCERT_FILE}"
|
||||
|
||||
exit 0
|
||||
|
||||
peer chaincode query \
|
||||
--connTimeout=30s \
|
||||
-C "${channel}" \
|
||||
-n "${ccName}" \
|
||||
--peerAddresses "${peerAddr}" \
|
||||
--tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}" \
|
||||
-c '{"Args":["query","b"]}'
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
# Invoke a chaincode
|
||||
# Usage: ./script mspId peerAddr mspPath=${PWD}/msp-mspId
|
||||
|
||||
# Entry function
|
||||
main() {
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Not enough argument supplied"
|
||||
echo "$(basename $0) mspId peerAddr mspPath=${PWD}/msp-mspId"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local mspId=$1
|
||||
local peerAddr=$2
|
||||
local mspPath=${3:-${PWD}/msp-${mspId}} # Suppose the local msp path named as msp-${msp_id}
|
||||
|
||||
export FABRIC_LOGGING_SPEC="debug"
|
||||
export CORE_PEER_ADDRESS="${peerAddr}"
|
||||
export CORE_PEER_LOCALMSPID=${mspId}
|
||||
export CORE_PEER_MSPCONFIGPATH=${mspPath}
|
||||
export CORE_PEER_TLS_ROOTCERT_FILE=${mspPath}/tlscacerts/tlsca.cert
|
||||
export CORE_PEER_TLS_ENABLED=true
|
||||
|
||||
#export GRPC_GO_REQUIRE_HANDSHAKE=off
|
||||
|
||||
peer chaincode list \
|
||||
--connTimeout=30s \
|
||||
--installed \
|
||||
--peerAddresses "${peerAddr}" \
|
||||
--tlsRootCertFiles "${CORE_PEER_TLS_ROOTCERT_FILE}"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -45,10 +45,10 @@ fetchConfigBlock() {
|
|||
--tls \
|
||||
--cafile "${tlscaFile}"
|
||||
|
||||
echo "[${channel}] Decode config block into JSON with configtxlator"
|
||||
echo "[${channel}] Decode config block into ${channel}_config.block.json"
|
||||
configtxlatorDecode "common.Block" "${channel}_config.block" "${channel}_config.block.json"
|
||||
|
||||
echo "[${channel}] Export the config section ${PAYLOAD_CFG_PATH} from config block"
|
||||
echo "[${channel}] Export the config section ${PAYLOAD_CFG_PATH} from config block into ${channel}_config.block.cfg.json"
|
||||
jq "${PAYLOAD_CFG_PATH}" "${channel}_config.block.json" >"${channel}_config.block.cfg.json"
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ main() {
|
|||
if [ $# -lt 3 ]; then
|
||||
echo "Not enough argument supplied"
|
||||
echo "$(basename $0) mspId channel ordererURL mspPath=${PWD}/msp-mspId"
|
||||
exit 1
|
||||
fi
|
||||
local mspId=$1
|
||||
local channel=$2
|
||||
|
|
Loading…
Reference in New Issue