@@ -15,8 +15,8 @@ initConfig(config);
1515Object . freeze ( config ) ;
1616console . log ( "config" , config ) ;
1717
18+ let bootnode = "" ;
1819const keys = gen_other . genXdposKeys ( ) ;
19-
2020const num_per_machine = Array ( config . num_machines ) ;
2121// integer division
2222for ( let i = 0 ; i < config . num_machines ; i ++ ) {
@@ -36,14 +36,13 @@ let doc = {
3636
3737let start_num = 1 ;
3838for ( let i = 1 ; i <= config . num_machines ; i ++ ) {
39- const subnet_nodes = gen_compose . genSubnetNodes (
39+ const nodes = genXdposCompose (
4040 ( machine_id = i ) ,
4141 ( num = num_per_machine [ i - 1 ] ) ,
4242 ( start_num = start_num ) ,
43- ( isXdpos = true )
4443 ) ;
4544 start_num += num_per_machine [ i - 1 ] ;
46- Object . entries ( subnet_nodes ) . forEach ( ( entry ) => {
45+ Object . entries ( nodes ) . forEach ( ( entry ) => {
4746 const [ key , value ] = entry ;
4847 doc [ "services" ] [ key ] = value ;
4948 } ) ;
@@ -84,6 +83,13 @@ function writeGenerated(output_dir) {
8483 }
8584 } ) ;
8685
86+ fs . writeFileSync ( `${ output_dir } /bootnodes.list` , bootnode , ( err ) => {
87+ if ( err ) {
88+ console . error ( err ) ;
89+ exit ( ) ;
90+ }
91+ } ) ;
92+
8793 fs . writeFileSync (
8894 `${ output_dir } /docker-compose.yml` ,
8995 compose_content ,
@@ -144,16 +150,12 @@ function copyScripts(output_dir) {
144150 `${ output_dir } /scripts/check-peer.sh`
145151 ) ;
146152 fs . copyFileSync (
147- `${ __dirname } /scripts/faucet .sh` ,
148- `${ output_dir } /scripts/faucet .sh`
153+ `${ __dirname } /scripts/docker-up .sh` ,
154+ `${ output_dir } /scripts/docker-up .sh`
149155 ) ;
150156 fs . copyFileSync (
151- `${ __dirname } /scripts/faucet-server.sh` ,
152- `${ output_dir } /scripts/faucet-server.sh`
153- ) ;
154- fs . copyFileSync (
155- `${ __dirname } /scripts/add-node.sh` ,
156- `${ output_dir } /scripts/add-node.sh`
157+ `${ __dirname } /scripts/docker-down.sh` ,
158+ `${ output_dir } /scripts/docker-down.sh`
157159 ) ;
158160}
159161
@@ -296,13 +298,14 @@ function genXdposNodeConfig(subnet_id, key, ip_record) {
296298 const wsport = 9555 + subnet_id - 1 ;
297299 const bootnode_ip =
298300 config . num_machines === 1 ? ip_record [ "bootnode" ] : config . ip_1 ;
301+ bootnode = `enode://cc566d1033f21c7eb0eb9f403bb651f3949b5f63b40683917\
302+ 765c343f9c0c596e9cd021e2e8416908cbc3ab7d6f6671a83c85f7b121c1872f8be\
303+ 50a591723a5d@${ bootnode_ip } :20301` ;
299304 const stats_ip = config . num_machines === 1 ? ip_record [ "stats" ] : config . ip_1 ;
300305 const config_env = `
301306INSTANCE_NAME=Masternode${ subnet_id }
302307PRIVATE_KEY=${ private_key }
303- BOOTNODES=enode://cc566d1033f21c7eb0eb9f403bb651f3949b5f63b40683917\
304- 765c343f9c0c596e9cd021e2e8416908cbc3ab7d6f6671a83c85f7b121c1872f8be\
305- 50a591723a5d@${ bootnode_ip } :20301
308+ BOOTNODES=${ bootnode }
306309NETWORK=local
307310NETWORK_ID=${ config . network_id }
308311RPC_API=db,eth,debug,miner,net,shh,txpool,personal,web3,XDPoS
@@ -314,3 +317,37 @@ LOG_LEVEL=2
314317
315318 return config_env ;
316319}
320+
321+
322+ function genXdposCompose ( machine_id , num , start_num = 1 ) {
323+ let nodes = { } ;
324+ for ( let i = start_num ; i < start_num + num ; i ++ ) {
325+ const node_name = "masternode" + i . toString ( ) ;
326+ const volume = "./xdcchain" + i . toString ( ) + ":/work/xdcchain" ;
327+ const compose_profile = "machine" + machine_id . toString ( ) ;
328+ const port = 20302 + i ;
329+ const rpcport = 8544 + i ;
330+ const wsport = 9554 + i ;
331+
332+ imageName = `xinfinorg/xdposchain:${ config . xdpos . xdposnode } ` ;
333+ config_path = "masternode" + i . toString ( ) + ".env" ;
334+
335+ nodes [ node_name ] = {
336+ image : imageName ,
337+ volumes : [ volume , "./genesis.json:/work/genesis.json" , "./bootnodes.list:/work/bootnodes.list" ] ,
338+ restart : "always" ,
339+ network_mode : "host" ,
340+ env_file : [ config_path ] ,
341+ profiles : [ compose_profile ] ,
342+ ports : [
343+ `${ port } :${ port } /tcp` ,
344+ `${ port } :${ port } /udp` ,
345+ `${ rpcport } :${ rpcport } /tcp` ,
346+ `${ rpcport } :${ rpcport } /udp` ,
347+ `${ wsport } :${ wsport } /tcp` ,
348+ `${ wsport } :${ wsport } /udp` ,
349+ ] ,
350+ } ;
351+ }
352+ return nodes ;
353+ }
0 commit comments