Skip to content

Commit 32e3db9

Browse files
outSHpetermetz
authored andcommitted
build: include cmd-socketio-server and socketio validators in the monorepo setup
Multiple changes in order to include cactus-cmd-socketio-server, and 3 connectors (fabric-socketio, go-ethereum-socketio and sawtooth-socketio) in common monorepo setup. They'll all build as part of root setup build. Also updated readme and done some other minor fixes related to this issue. Closes: #1647 Signed-off-by: Michal Bajer <[email protected]>
1 parent 634b10e commit 32e3db9

File tree

22 files changed

+383
-1372
lines changed

22 files changed

+383
-1372
lines changed

examples/cartrade/README.md

Lines changed: 95 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -15,130 +15,123 @@ Cactus **car-trade** is a sample application where users can exchange car owners
1515
## Prerequisites
1616

1717
- Available ports:
18-
- `5034`: the port of `cactus-cmd-socker-server`
19-
- `5040`: the port of `cactus-plugin-ledger-connector-fabric-socketio`
20-
- `5050`: the port of `cactus-plugin-ledger-connector-go-ethereum-socketio`
21-
- If it is already used, the following processes can be done by changing the port number setting
18+
- `5034`: the port of `cactus-cmd-socketio-server`
19+
- `5040`: the port of `cactus-plugin-ledger-connector-fabric-socketio`
20+
- `5050`: the port of `cactus-plugin-ledger-connector-go-ethereum-socketio`
21+
- If it is already used, the following processes can be done by changing the port number setting
2222
- Available directory (This directory must be empty):
23-
- `/etc/cactus`: the directory for storing the config files of `cactus-cmd-socket-server`
23+
- `/etc/cactus`: the directory for storing the config files of `cactus-cmd-socket-server`
2424

2525
## Boot method
2626

2727
1. Before booting, please prepare the directory for storing config files on the directoty `/etc/cactus` on your server
28-
```
29-
sudo mkdir /etc/cactus
30-
sudo chmod 777 /etc/cactus
31-
```
28+
```
29+
sudo mkdir /etc/cactus
30+
sudo chmod 777 /etc/cactus
31+
```
3232
3333
1. Before booting, please modify `applicationHostInfo.hostName` and `applicationHostInfo.hostPort` on `cactus/etc/cactus/default.yaml` to adjust to your environment.
34-
```
35-
vi cactus/etc/cactus/default.yaml
34+
```
35+
vi cactus/etc/cactus/default.yaml
3636
37-
[cactus/etc/cactus/default.yaml]
38-
applicationHostInfo:
39-
hostName: http://aaa.bbb.ccc.ddd # please change hostName to your IP address
40-
hostPort: 5034 # if you want to change the port number, please change hostPort to the port number which you want to use
41-
```
37+
[cactus/etc/cactus/default.yaml]
38+
applicationHostInfo:
39+
hostName: http://aaa.bbb.ccc.ddd # please change hostName to your IP address
40+
hostPort: 5034 # if you want to change the port number, please change hostPort to the port number which you want to use
41+
```
4242
4343
1. Start ledgers:
44-
```
45-
./script-start-ledgers.sh
46-
```
47-
- (NOTICE: Before executing the above, your account needs to be added to the docker group (`usermod -a -G docker YourAccount` from root user))
48-
- If the following containers are started when displaying the container list with the docker ps command, it will be fine.
49-
```
50-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51-
14b98ba40b66 dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba "chaincode -peer.add…" 42 seconds ago Up 40 seconds dev-peer0.org1.example.com-fabcar-1.0
52-
d0efd7479bdd hyperledger/fabric-tools "/bin/bash" About a minute ago Up 56 seconds cli
53-
c9bd7ddfde7e hyperledger/fabric-peer "peer node start" About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
54-
d4f2b1a76626 hyperledger/fabric-couchdb "tini -- /docker-ent…" About a minute ago Up About a minute 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
55-
53a79780f564 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" About a minute ago Up About a minute 0.0.0.0:7054->7054/tcp ca.example.com
56-
aceb0e52e9c7 hyperledger/fabric-orderer "orderer" About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com
57-
ec57c9f78d0d ethereum/client-go:v1.8.27 "geth --rpc --networ…" 2 minutes ago Up 2 minutes 8546/tcp, 0.0.0.0:8545->8545/tcp, 30303/tcp, 30303/udp geth1
58-
```
44+
```
45+
./script-start-ledgers.sh
46+
```
47+
- (NOTICE: Before executing the above, your account needs to be added to the docker group (`usermod -a -G docker YourAccount` from root user))
48+
- If the following containers are started when displaying the container list with the docker ps command, it will be fine.
49+
```
50+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51+
14b98ba40b66 dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba "chaincode -peer.add…" 42 seconds ago Up 40 seconds dev-peer0.org1.example.com-fabcar-1.0
52+
d0efd7479bdd hyperledger/fabric-tools "/bin/bash" About a minute ago Up 56 seconds cli
53+
c9bd7ddfde7e hyperledger/fabric-peer "peer node start" About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
54+
d4f2b1a76626 hyperledger/fabric-couchdb "tini -- /docker-ent…" About a minute ago Up About a minute 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
55+
53a79780f564 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" About a minute ago Up About a minute 0.0.0.0:7054->7054/tcp ca.example.com
56+
aceb0e52e9c7 hyperledger/fabric-orderer "orderer" About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com
57+
ec57c9f78d0d ethereum/client-go:v1.8.27 "geth --rpc --networ…" 2 minutes ago Up 2 minutes 8546/tcp, 0.0.0.0:8545->8545/tcp, 30303/tcp, 30303/udp geth1
58+
```
5959
6060
1. Please prepare the three consoles on your machine as the following:
61-
- **console 1**: console for launching `cactus-plugin-ledger-connector-go-ethereum-socketio`
62-
- **console 2**: console for launching `cactus-plugin-ledger-connector-fabric-socketio`
63-
- **console 3**: console for launching `cactus-cmd-socker-server` including `cartrade` business logic application.
61+
- **console 1**: console for launching `cactus-plugin-ledger-connector-go-ethereum-socketio`
62+
- **console 2**: console for launching `cactus-plugin-ledger-connector-fabric-socketio`
63+
- **console 3**: console for launching `cactus-cmd-socketio-server` including `cartrade` business logic application.
6464
6565
1. Launch the validators:
66-
- Please execute [the boot methods](../../packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md#boot-methods) of `cactus-plugin-ledger-connector-go-ethereum-socketio` on the **console 1** using the port `5050`
67-
- Please execute [the boot methods](../../packages/cactus-plugin-ledger-connector-fabric-socketio/README.md#boot-methods) of `cactus-plugin-ledger-connector-fabric-socketio` on the **console 2** using the port `5040`
68-
69-
2. Launch `cactus-cmd-socker-server` including `cartrade` business logic application
70-
- Use the **console 3**
71-
- Install and build npm packages on `cactus-cmd-socker-server`
72-
```
73-
cd cactus/packages/cactus-cmd-socker-server
74-
npm install
75-
npm run build
76-
```
77-
- Install and build npm packages on `cactus/examples/cartrade`
78-
```
79-
cd cactus/examples/cartrade
80-
npm install
81-
npm run build
82-
```
83-
- Create the symbolic link to node_modules. This script is enough to execute only once.
84-
```
85-
cd cactus/examples/cartrade
86-
npm run init-cartrade
87-
```
88-
- Launch the `cactus-cmd-server-socket` `cactus-cmd-socker-server` including `cartrade` business logic application
89-
```
90-
cd cactus/examples/cartrade
91-
npm run start
92-
```
93-
- After executing the above script, `cactus-cmd-socker-server` is launched on the port `5034`.
66+
- Please execute [the boot methods](../../packages/cactus-plugin-ledger-connector-go-ethereum-socketio/README.md#boot-methods) of `cactus-plugin-ledger-connector-go-ethereum-socketio` on the **console 1** using the port `5050`
67+
- Please execute [the boot methods](../../packages/cactus-plugin-ledger-connector-fabric-socketio/README.md#boot-methods) of `cactus-plugin-ledger-connector-fabric-socketio` on the **console 2** using the port `5040`
68+
69+
2. Launch `cactus-cmd-socketio-server` including `cartrade` business logic application
70+
- Use the **console 3**
71+
- Build base npm packages (including `cactus-cmd-socketio-server`) from cactus root directory
72+
```
73+
npm run configure
74+
```
75+
- Install and build npm packages on `examples/cartrade`
76+
```
77+
cd ./examples/cartrade
78+
npm install
79+
npm run build
80+
```
81+
- Launch the `cactus-cmd-socketio-server` including `cartrade` business logic application
82+
```
83+
cd ./examples/cartrade
84+
npm run start
85+
```
86+
- After executing the above script, `cactus-cmd-socketio-server` is launched on the port `5034`.
9487
9588
## How to use this application
9689
9790
1. (Optional) Check the balance on Ethereum and the fabcar ownership on Fabric using the following script
98-
- `./script-build-get-app.sh` (only the first time)
99-
- `./script-get-app.sh`
100-
- The result is as the following:
101-
```
102-
[process] Execute an app for getting Balance on Ethereum
103-
The balance of fromAccount:
104-
BigNumber { s: 1, e: 4, c: [ 100000 ] }
105-
The balance of toAccount:
106-
BigNumber { s: 1, e: 1, c: [ 0 ] }
107-
[process] Execute an app for getting ownership on Fabcar
108-
##queryCar Params: CAR1
109-
Transaction has been evaluated, result is: {"colour":"red","make":"Ford","model":"Mustang","owner":"Brad"}
110-
```
91+
- `./script-build-get-app.sh` (only the first time)
92+
- `./script-get-app.sh`
93+
- The result is as the following:
94+
```
95+
[process] Execute an app for getting Balance on Ethereum
96+
The balance of fromAccount:
97+
BigNumber { s: 1, e: 4, c: [ 100000 ] }
98+
The balance of toAccount:
99+
BigNumber { s: 1, e: 1, c: [ 0 ] }
100+
[process] Execute an app for getting ownership on Fabcar
101+
##queryCar Params: CAR1
102+
Transaction has been evaluated, result is: {"colour":"red","make":"Ford","model":"Mustang","owner":"Brad"}
103+
```
111104
1. Run the transaction execution using the following script
112-
```
113-
curl localhost:5034/api/v1/bl/trades/ -XPOST -H "Content-Type: application/json" -d '{"businessLogicID":"guks32pf","tradeParams":["0x06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97", "0x9d624f7995e8bd70251f8265f2f9f2b49f169c55", "Brad", "Cathy", 50, "CAR1"],"authParams":["none"]}'
114-
```
115-
- `./script-post-cartrade-sample.sh`
116-
- After this, the transactions are executed by order. When the following log appears on the above third console (the console of `./script-start-cartrade.sh`), the transactions are completed.
117-
```
118-
[INFO] BusinessLogicCartrade - ##INFO: completed cartrade, businessLogicID: guks32pf, tradeID: *******-001
119-
```
105+
```
106+
curl localhost:5034/api/v1/bl/trades/ -XPOST -H "Content-Type: application/json" -d '{"businessLogicID":"guks32pf","tradeParams":["0x06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97", "0x9d624f7995e8bd70251f8265f2f9f2b49f169c55", "Brad", "Cathy", 50, "CAR1"],"authParams":["none"]}'
107+
```
108+
- `./script-post-cartrade-sample.sh`
109+
- After this, the transactions are executed by order. When the following log appears on the above third console (the console of `./script-start-cartrade.sh`), the transactions are completed.
110+
```
111+
[INFO] BusinessLogicCartrade - ##INFO: completed cartrade, businessLogicID: guks32pf, tradeID: *******-001
112+
```
120113
1. (Optional) Check the balance on Ethereum and the fabcar ownership on Fabric using the following script
121-
- `./script-get-app.sh`
122-
- The result is as the following. In the following case, 50 coins from fromAccount was transferred to toAccount, and the car ownership ("owner") was transferred.
123-
```
124-
[process] Execute an app for getting Balance on Ethereum
125-
The balance of fromAccount:
126-
BigNumber { s: 1, e: 4, c: [ 99950 ] }
127-
The balance of toAccount:
128-
BigNumber { s: 1, e: 1, c: [ 50 ] }
129-
[process] Execute an app for getting ownership on Fabcar
130-
##queryCar Params: CAR1
131-
Transaction has been evaluated, result is: {"colour":"red","make":"Ford","model":"Mustang","owner":"Cathy"}
132-
```
114+
- `./script-get-app.sh`
115+
- The result is as the following. In the following case, 50 coins from fromAccount was transferred to toAccount, and the car ownership ("owner") was transferred.
116+
```
117+
[process] Execute an app for getting Balance on Ethereum
118+
The balance of fromAccount:
119+
BigNumber { s: 1, e: 4, c: [ 99950 ] }
120+
The balance of toAccount:
121+
BigNumber { s: 1, e: 1, c: [ 50 ] }
122+
[process] Execute an app for getting ownership on Fabcar
123+
##queryCar Params: CAR1
124+
Transaction has been evaluated, result is: {"colour":"red","make":"Ford","model":"Mustang","owner":"Cathy"}
125+
```
133126
134127
## How to stop the application and Docker containers
135128
136-
1. Stop the validators and `cactus-cmd-server-socket`
137-
- Press Ctrl+C on the above the **console 1, 2, and 3**.
129+
1. Stop the validators and `cactus-cmd-socketio-server`
130+
- Press Ctrl+C on the above the **console 1, 2, and 3**.
138131
1. Remove the config files on your machine
139-
```
140-
sudo rm -r /etc/cactus/
141-
```
132+
```
133+
sudo rm -r /etc/cactus/
134+
```
142135
1. Stop the docker containers of Ethereum and Fabric
143-
- Press the command `docker stop <CONTAINER ID>` to stop the container corresponding to the above containers which were launched by `./script-start-ledgers.sh` on the boot method. If you want to destroy the docker containers, press the command `docker rm <CONTAINER ID>` after the above.
144-
- If any other docker containers are not running on your machine, you can destroy the Docker containers only with `docker ps -aq | xargs docker stop` and `docker ps -aq | xargs docker rm`.
136+
- Press the command `docker stop <CONTAINER ID>` to stop the container corresponding to the above containers which were launched by `./script-start-ledgers.sh` on the boot method. If you want to destroy the docker containers, press the command `docker rm <CONTAINER ID>` after the above.
137+
- If any other docker containers are not running on your machine, you can destroy the Docker containers only with `docker ps -aq | xargs docker stop` and `docker ps -aq | xargs docker rm`.

examples/cartrade/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"scripts": {
55
"start": "node ../../dist/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/www.js",
66
"debug": "nodemon --inspect ../../dist/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/www.js",
7-
"build": "npm run build-ts && npm run copy-static-assets && npm run copy-blp-config && npm run replace-blp-config-path",
7+
"build": "npm run build-ts && npm run copy-static-assets && npm run copy-blp-config && npm run replace-blp-config-path && npm run init-cartrade",
88
"build-ts": "tsc -p ./tsconfig.json",
99
"tslint": "tslint -c tslint.json -p tsconfig.json './*.ts'",
1010
"copy-static-assets": "ts-node copyStaticAssets.ts",
1111
"copy-blp-config": "ts-node copyBLPConfig.ts",
1212
"replace-blp-config-path": "ts-node replaceBLPConfigPath.ts",
13-
"init-cartrade": "ln -s ../examples/cartrade/node_modules ../../dist/node_modules"
13+
"init-cartrade": "ln -fs ../examples/cartrade/node_modules ../../dist/node_modules"
1414
},
1515
"dependencies": {
1616
"@types/node": "^14.0.24",

0 commit comments

Comments
 (0)