Giter Site home page Giter Site logo

Comments (12)

qiang0723 avatar qiang0723 commented on August 10, 2024 1

I mean each time you want to re-start fabric network , clean both container and new-generated-images first, like

docker ps
2f20f7a46ef9        dev-peer1.org2.example.com-mycc-1.0   "chaincode -peer.addr"   Less than a second ago   Up 8 seconds                                                                                                                 dev-peer1.org2.example.com-mycc-1.0
dbbfb49276a2        dev-peer1.org1.example.com-mycc-1.0   "chaincode -peer.addr"   Less than a second ago   Up 27 seconds                                                                                                                dev-peer1.org1.example.com-mycc-1.0
f34b05b3b38b        dev-peer0.org2.example.com-mycc-1.0   "chaincode -peer.addr"   Less than a second ago   Up About a minute

and new-generated-images

docker images
dev-peer1.org2.example.com-mycc-1.0   latest                 ffa42829b2ef        Less than a second ago   172.9 MB
dev-peer1.org1.example.com-mycc-1.0   latest                 4bd694f8f60a        Less than a second ago   172.9 MB
dev-peer0.org2.example.com-mycc-1.0   latest                 1710aae8e3d8        Less than a second ago   172.9 MB

and delete them all

echo "clean containers...."
docker rm -f `docker ps -aq`

echo "clean images ..."
docker rmi -f `docker images|grep mycc-1.0|awk '{print $3}'`

from docker-compose-files.

qiang0723 avatar qiang0723 commented on August 10, 2024

According to your problem description and my understanding, I can provide a way.
You can add a volumes at service cli in docker-compose-2orgs-4peers.yaml .
like this:
"""
volumes:
#- ./e2e_cli/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples
"""
Putting your changed chaincode in ./e2e_cli/examples.
Hope can help you.

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024

Thanks for the response, I have already tried it without success.
More specifically, I have placed my chaincode inside e2e_cli/examples/chaincode/go/chaincode_example02/chaincode_example02.go file. I have uncommented the line you suggested, and then I ran the initialize.sh script. However it seems that the default chaincode is still installed.

What should be the path (-p) value in the peer chaincode install command? I have it set to the default github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02.

from docker-compose-files.

yeasy avatar yeasy commented on August 10, 2024

@thanosgn it would be helpful if you could post the detailed steps to repeat.

cannot guess out what happens...

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024
  1. Edit the e2e_cli/examples/chaincode/go/chaincode_example02/chaincode_example02.go and place custom chaincode. (e.g. change the invoke function)
  2. Copy e2e_cli/examples/chaincode/go/chaincode_example02/chaincode_example02.go file in all 6 containers (fabric-cli, peer1.org2.example.com, peer0.org1.example.com, peer1.org1.example.com, peer0.org2.example.com, orderer.example.com) using docker cp command. The file is placed in /go/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 directory.
  3. Edit docker-compose-2orgs-4peers.yaml and uncomment line 61, as suggested above.
  4. Run docker-compose -f docker-compose-2orgs-4peers.yaml up -d (I have previously removed all docker containers).
  5. Enter the fabric-cli container
  6. Run scripts/initialize.sh script
  7. Call the invoke function or anything else that tests your chaincode. E.g. you could run scripts/test_4peers.sh

After doing theese steps, I cannot execute my own chaincode, but I keep getting the results from the "default" chaincode that was initially in /go/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02/chaincode_example02.go

from docker-compose-files.

qiang0723 avatar qiang0723 commented on August 10, 2024

@thanosgn I just test with following steps, just like yours

  1. Add some test label in chaincode_example02.go, such as change Println.
  2. Uncomment line 61

then I get the output look like:
"""
ex02 Init======test whether is replaced or still default chaincode =====================================================
Aval = 100, Bval = 200
ex02 Invoke======test whether is replaced or still default chaincode =====================================================
Query Response:{"Name":"a","Amount":"100"}
"""
Obviously using the changed one.

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024

Have you followed the seven steps that I suggested? If not, can you please provide a step by step execution? I frankly could not manage to execute my chaincode whatever I tried.

from docker-compose-files.

qiang0723 avatar qiang0723 commented on August 10, 2024

OK, this is my steps and whether it meets your test requirements?

  1. Change something in "https://github.com/yeasy/docker-compose-files/blob/master/hyperledger/1.0/e2e_cli/examples/chaincode/go/chaincode_example02/chaincode_example02.go"
  1. change invoke to invoke_test
  2. change fmt.Println("ex02 Init") to fmt.Println("ex02 Init===has been changed===")
    change fmt.Println("ex02 Invoke") to fmt.Println("ex02 Invoke===has been changed to Invoke_test====")
  1. Uncomment line 61 in "https://github.com/yeasy/docker-compose-files/blob/master/hyperledger/1.0/docker-compose-2orgs-4peers.yaml"

  2. Change invoke to invoke_test at line 93,95 in test_4.sh, such as {"Args":["invoke_test","a","b","10"]}'

  3. docker-compose -f docker-compose-2orgs-4peers.yaml up

  4. in container execute bash ./scripts/initailize.sh and bash ./scripts/test_4.sh

  5. then check the log at new generated container:

$ docker logs 819a5679e94b
ex02 Init===has been changed===
Aval = 100, Bval = 200
ex02 Invoke===has been changed to Invoke_test====
Query Response:{"Name":"a","Amount":"100"}

$ docker logs af1c137ccb26
ex02 Invoke===has been changed to Invoke_test====
Query Response:{"Name":"a","Amount":"90"}
ex02 Invoke===has been changed to Invoke_test====
Aval = 80, Bval = 220
ex02 Invoke===has been changed to Invoke_test====
Query Response:{"Name":"a","Amount":"80"}

$ docker logs af1c137ccb26
ex02 Invoke===has been changed to Invoke_test====
Query Response:{"Name":"a","Amount":"90"}
ex02 Invoke===has been changed to Invoke_test====
Aval = 80, Bval = 220
ex02 Invoke===has been changed to Invoke_test====
Query Response:{"Name":"a","Amount":"80"}

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024

I followed your steps exactly but made no difference. The only step that differed was 4, where I ran sudo docker-compose -f docker-compose-2orgs-4peers-event.yaml up -d instead of sudo docker-compose -f docker-compose-2orgs-4peers-event.yaml up. For some reason I get a lot of errors without the -d parameter.
My output was the following:

sudo docker logs 510753bb903c
ex02 Invoke
Query Response:{"Name":"a","Amount":"90"}
ex02 Invoke
Aval = 80, Bval = 220
ex02 Invoke
Query Response:{"Name":"a","Amount":"80"}

sudo docker logs 431b719bf66d
ex02 Invoke
Aval = 90, Bval = 210

sudo docker logs c34605c0dc80
ex02 Init
Aval = 100, Bval = 200
ex02 Invoke
Query Response:{"Name":"a","Amount":"100"}

from docker-compose-files.

qiang0723 avatar qiang0723 commented on August 10, 2024

The version of docker doesn't matter, Check whether rmi new-generate images like dev-peer0.org2.example.com-mycc-1.0

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024

@qiang0723 Thanks for your help! Can you please explain the last comment a bit more? I could not understand what you suggested.

from docker-compose-files.

thanosgn avatar thanosgn commented on August 10, 2024

Thank you! The solution was to remove the newly generated images as well as the containers, as you suggested.

from docker-compose-files.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.