Browse Source

Allows to create more nodes

cserri-tw 2 years ago
parent
commit
47ebd21609
3 changed files with 11 additions and 3463 deletions
  1. 3 3
      ethereum-private/README.md
  2. 8 13
      ethereum-private/go.sh
  3. 0 3447
      ethereum-private/package-lock.json

+ 3 - 3
ethereum-private/README.md

@@ -8,11 +8,11 @@ TODO (Brew install ethereum and geth)
8 8
 
9 9
 ## Start the node(s)
10 10
 
11
-The script allows you to start 2 nodes on your local machine (`node1` and `node2`).
11
+The script allows you to start up to *9* nodes on your local machine (`node0`, `node1`, `node3` etc).
12 12
 To start a node run the script passing start and the node name as arguments:
13 13
 
14 14
 ```
15
-./go.sh start node1
15
+./go.sh start node0
16 16
 ```
17 17
 
18 18
 ## Attach javascript console
@@ -20,7 +20,7 @@ To start a node run the script passing start and the node name as arguments:
20 20
 In a new terminal window you can attach a javascript console to interact with the node:
21 21
 
22 22
 ```
23
-./go.sh console node1
23
+./go.sh console node0
24 24
 ```
25 25
 
26 26
 In the console you can:

+ 8 - 13
ethereum-private/go.sh

@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2
-PORT_NODE1="30301"
3
-PORT_NODE2="30302"
4
-RPC_PORT_NODE1="8101"
5
-RPC_PORT_NODE2="8102"
2
+BASE_PORT="3030"
3
+BASE_RPC_PORT="810"
6 4
 NETWORK_ID="791"
7 5
 APP_CORS_DOMAIN="http://localhost:8000"
8 6
 
@@ -13,12 +11,9 @@ init() {
13 11
 
14 12
 start() {
15 13
   init
16
-  PORT=$PORT_NODE1
17
-  RPC_PORT=$RPC_PORT_NODE1
18
-  if [ $NODE == "node2" ]; then
19
-    PORT=$PORT_NODE2
20
-    RPC_PORT=$RPC_PORT_NODE2
21
-  fi
14
+  NODE_NUMBER=${NODE:4}
15
+  PORT=$BASE_PORT$NODE_NUMBER
16
+  RPC_PORT=$BASE_RPC_PORT$NODE_NUMBER
22 17
   echo "Starting $NODE"
23 18
   geth --datadir $PWD/nodes/$NODE --port $PORT --rpc --rpcport $RPC_PORT --networkid $NETWORK_ID --nodiscover --verbosity 5 --rpccorsdomain $APP_CORS_DOMAIN --ipcpath $PWD/nodes/$NODE/geth.ipc
24 19
 }
@@ -29,12 +24,12 @@ console() {
29 24
 
30 25
 usage() {
31 26
   echo "Usage:"
32
-  echo "start   <node1 (default if no name), node2> : starts the node in the network"
33
-  echo "console <node1 (default if no name), node2> : attaches a js console to the node"
27
+  echo "start   <node name from 0 to 9 (node0, node1, node2 etc.)> : starts the node in the network"
28
+  echo "console <node name from 0 to 9 (node0, node1, node2 etc.)> : attaches a js console to the node"
34 29
 }
35 30
 
36 31
 OPTION="$1"
37
-[ ! -z $2 ] && NODE="$2" || NODE="node1"
32
+[ ! -z $2 ] && NODE="$2" || NODE="node0"
38 33
   case $OPTION in
39 34
     start)
40 35
       start

File diff suppressed because it is too large
+ 0 - 3447
ethereum-private/package-lock.json