1
1
# What is block-listener
2
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.
3
+ events (if there are chaincode events being sent).
5
4
6
5
# To Run
7
6
``` sh
@@ -13,10 +12,17 @@ Please note that the default MSP under fabric/sampleconfig will be used if no
13
12
MSP parameters are provided.
14
13
15
14
# 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 `` .
15
+ The block listener can be used with TLS enabled or disabled. By default,
16
+ the e2e_cli example will have TLS enabled. In order to allow the
17
+ block-listener sample to connect to peers on e2e_cli example with a TLS
18
+ enabled, the easiest way would be to map 127.0.0.1 to the hostname of peer
19
+ that you are connecting to, such as peer0.org1.example.com. For example on
20
+ \* nix based systems this would be an entry in /etc/hosts file.
21
+
22
+ If you would prefer to disable TLS, you may do so by setting
23
+ CORE_PEER_TLS_ENABLED=*** false*** in `` docker-compose-cli.yaml `` and
24
+ `` base/peer-base.yaml `` as well as
25
+ ORDERER_GENERAL_TLS_ENABLED=*** false*** in`` base/docker-compose-base.yaml `` .
20
26
21
27
Next, run the [ e2e_cli example] ( https://github.com/hyperledger/fabric/tree/master/examples/e2e_cli ) .
22
28
@@ -25,30 +31,48 @@ Once the "All in one" command:
25
31
./network_setup.sh up
26
32
```
27
33
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):
34
+ the following (assuming you are running block-listener in the host environment)
35
+ if TLS is enabled:
36
+ ``` sh
37
+ CORE_PEER_TLS_ENABLED=true CORE_PEER_TLS_ROOTCERT_FILE=$GOPATH /src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt ./block-listener -events-address=peer0.org1.example.com: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
38
+ ```
39
+
40
+ If TLS is disabled, you can simply run:
29
41
``` 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
42
+ ./block-listener -events-address=peer0.org1.example.com :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
43
```
32
44
33
- The event client should output "Event Address: 127.0.0.1 :7053" and wait for
34
- events.
45
+ The event client should output "Event Address: peer0.org1.example.com :7053"
46
+ and wait for events.
35
47
36
48
Exec into the cli container:
37
49
38
50
``` sh
39
51
docker exec -it cli bash
40
52
```
41
- Setup the environment variables for peer0.org1.example.com
53
+
54
+ Next, setup the environment variables for peer0.org1.example.com.
55
+ If TLS is enabled:
56
+ ``` sh
57
+ CORE_PEER_MSPCONFIGPATH=$GOPATH /src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
58
+ CORE_PEER_ADDRESS=peer0.org1.example.com:7051
59
+ CORE_PEER_LOCALMSPID=" Org1MSP"
60
+ ORDERER_CA=$GOPATH /src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
61
+ ```
62
+ If TLS is disabled:
42
63
``` sh
43
64
CORE_PEER_MSPCONFIGPATH=$GOPATH /src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
44
65
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
45
66
CORE_PEER_LOCALMSPID=" Org1MSP"
46
67
```
47
68
48
- Create an invoke transaction:
49
-
69
+ Create an invoke transaction. If TLS is enabled:
70
+ ``` sh
71
+ peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
72
+ ```
73
+ If TLS is disabled:
50
74
``` sh
51
- peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c ' {"Args":["invoke","a","b","10"]}'
75
+ peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
52
76
```
53
77
Now you should see the block content displayed in the terminal running the block
54
78
listener.
0 commit comments