github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/examples/events/block-listener/README.md (about) 1 # What is block-listener 2 block-listener.go connects to a peer in order to receive block and chaincode 3 events (if there are chaincode events being sent). Currently, this example only 4 works with TLS disabled in the environment. 5 6 # To Run 7 ```sh 8 1. go build 9 10 2. ./block-listener -events-address=<peer-address> -events-from-chaincode=<chaincode-id> -events-mspdir=<msp-directory> -events-mspid=<msp-id> 11 ``` 12 Please note that the default MSP under fabric/sampleconfig will be used if no 13 MSP parameters are provided. 14 15 # Example with the e2e_cli example 16 In order to use the block listener with the e2e_cli example, make sure that TLS 17 has been disabled by setting CORE_PEER_TLS_ENABLED=***false*** in 18 ``docker-compose-cli.yaml``, ``base/docker-compose-base.yaml`` and 19 ``base/peer-base.yaml``. 20 21 Next, run the [e2e_cli example](https://github.com/hyperledger/fabric/tree/master/examples/e2e_cli). 22 23 Once the "All in one" command: 24 ```sh 25 ./network_setup.sh up 26 ``` 27 has completed, attach the event client to peer peer0.org1.example.com by doing 28 the following (assuming you are running block-listener in the host environment): 29 ```sh 30 ./block-listener -events-address=127.0.0.1:7053 -events-mspdir=$GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp -events-mspid=Org1MSP 31 ``` 32 33 The event client should output "Event Address: 127.0.0.1:7053" and wait for 34 events. 35 36 Exec into the cli container: 37 38 ```sh 39 docker exec -it cli bash 40 ``` 41 Setup the environment variables for peer0.org1.example.com 42 ```sh 43 CORE_PEER_MSPCONFIGPATH=$GOPATH/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 44 CORE_PEER_ADDRESS=peer0.org1.example.com:7051 45 CORE_PEER_LOCALMSPID="Org1MSP" 46 ``` 47 48 Create an invoke transaction: 49 50 ```sh 51 peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' 52 ``` 53 Now you should see the block content displayed in the terminal running the block 54 listener. 55 56 57 <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.