问题描述
我是超级账本结构的新手,安装了所有前提条件,超级账本结构fabcar链代码可以正确运行,但是当我在hyperledger fabic链代码中更改fabcar.go并运行它时,将显示旧车,并且没有任何变化接受.
I am new in hyperledger fabric and install all the pre requirement and hyperledger fabric fabcar chain code is run correctly but when I changed fabcar.go in hyperledger fabic chain code and when I run it the old cars will be show and no changes accepted.
我读过类似的问题,但答案尚不清楚,请详细告诉我如何删除先前在sample-fabric/chaincode/fabcar/go/fabric.go中编写的链代码并安装新的链代码.
I read similar question but answer is not clear please tell me in detail how to delete the previous chain code and install new chain code that I write in sample-fabric/chaincode/fabcar/go/fabric.go
请帮助我,我将非常感激自3天以来陷入这一问题.
Please help me I will very thankful I am stuck in this problem since 3 days.
以下是在startFabric.sh文件代码中
following is in startFabric.sh file code
#!/bin/bash
#
# Copyright IBM Corp All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
# Exit on first error
set -e
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
starttime=$(date +%s)
LANGUAGE=${1:-"golang"}
CC_SRC_PATH=github.com/mychain/go
if [ "$LANGUAGE" = "node" -o "$LANGUAGE" = "NODE" ]; then
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/node
fi
# clean the keystore
rm -rf ./hfc-key-store
# launch network; create channel and join peer to channel
cd ../basic-network
./start.sh
# Now launch the CLI container in order to install, instantiate chaincode
# and prime the ledger with our 10 cars
docker-compose -f ./docker-compose.yml up -d cli
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli peer chaincode install -n fabcar -v 1.0 -p "$CC_SRC_PATH" -l "$LANGUAGE"
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n fabcar -l "$LANGUAGE" -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
sleep 10
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar -c '{"function":"initLedger","Args":[""]}'
printf "\nTotal setup execution time : $(($(date +%s) - starttime)) secs ...\n\n\n"
printf "Start by installing required packages run 'npm install'\n"
printf "Then run 'node enrollAdmin.js', then 'node registerUser'\n\n"
printf "The 'node invoke.js' will fail until it has been updated with valid arguments\n"
printf "The 'node query.js' may be run at anytime once the user has been registered\n\n"
推荐答案
如果您想通过更改fabcar.go链码上的参数来与"fabcar"链码进行交互,则首先您必须停止网络然后删除所有先前的网络模块,然后进入fabcar.go文件,更改汽车列表,然后再次启动网络,应将旧汽车列表更改为最新列表.为此,您有2个选择:
If you'd like to interact with th "fabcar" chaincode by changing the parameters on the fabcar.go chaincode, firstly u have to stop the network then remove all previous network modules, then enter the fabcar.go file, change cars' list, then bring the network up again, it should change old cars' list to the newest one. For this, u have 2 options:
1)创建teardown.sh脚本文件:
1) create teardown.sh script file:
$teardown.sh (script file source code)
set -e
#Shut down the Docker containers for the system tests.
docker-compose -f docker-compose.yml kill && docker-compose -f docker-compose.yml
down
# remove chaincode docker images
docker rmi $(docker images dev-* -q)
2)删除节点模块,并修剪docker卷:
2) delete node-modules, and prune docker volume:
$cd...fabric-samples/fabcar/javascript
$rmdir node_modules
$docker stop $(docker ps -a -q)
$docker rm $(docker ps -a -q)
$ docker volume prune
$cd...fabric-samples/fabcar
$startFabric.sh
$cd...fabric-samples/fabcar/javascript
$npm install -g
$node query.js
这篇关于超级账本的fabcar.go链码不接受更改和修改,并且始终运行先前的链码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!