-
Notifications
You must be signed in to change notification settings - Fork 1
/
walton.sh
executable file
·551 lines (528 loc) · 22 KB
/
walton.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
#!/bin/bash
#Only save this file with LF (linefeed), not windows default of CRLF, use notepad++ to ensure this.
#Notepad++/VSCode/Sublimetext displays which LF/CRLF it will be saving it with in the bottom right.
#You should call this script like: source walton.sh or equivalently: . ./walton.sh
#The results are stored in results.txt, which is best viewable with anything other than notepad.
#FOR ADVANCED CONFIGURATION: Look in the wMain() function at the bottom of the script.
unset NUMBER_OF_WALTONS
unset WALLET
unset EXTRA_DATA
unset RPC_PORT
unset IP
declare -a NUMBER_OF_WALTONS
declare -a WALLET
declare -a EXTRA_DATA
declare -a RPC_PORT
declare -a IP
################################[USER OPTIONS]#####################################\
NUM_OF_RIGS=1
###RIG1###
NUMBER_OF_WALTONS[0]=2 #walton.exe's
WALLET[0]=0xf3faf814cd115ebba078085a3331774b762cf5ee
EXTRA_DATA[0]=glyph #less than or equal to 31 characters
RPC_PORT_START[0]=8545
IP[0]=127.0.0.1
###RIG2###
#NUMBER_OF_WALTONS[1]=1
#WALLET[1]=0xf3faf814cd115ebba078085a3331774b762cf5ee
#EXTRA_DATA[1]=glyph
#RPC_PORT_START[1]=8545
#IP[1]=127.0.0.1
###RIG3###
#NUMBER_OF_WALTONS[2]=1
#WALLET[2]=0xf3faf814cd115ebba078085a3331774b762cf5ee
#EXTRA_DATA[2]=glyph
#RPC_PORT_START[2]=8545
#IP[2]=127.0.0.1
################################[USER OPTIONS]#####################################/
unset RPC_PORTS
unset PEERS
unset peerCount
unset ENODE_ZEROS
declare -a RPC_PORTS
declare -a PEERS
declare -a peerCount
declare -a ENODE_ZEROS
CT="Content-Type:application/json"
echo " " > results.txt
red=$'\e[1;31m'
grn=$'\e[32m'
yel=$'\e[33m'
blu=$'\e[34m'
mag=$'\e[35m'
cyn=$'\e[36m'
end=$'\e[0m' #produced different color results -- figure out why.
function enumRPCPorts () {
for ((i=0;i<${NUMBER_OF_WALTONS[$1]};i++)); do
RPC_PORTS[$i]=$(($RPC_PORT_START+$i))
done
}
function stripColors () {
sed "s/\x1B\[\([0-9]\{1,2\}\(;[0-9]\{1,2\}\)\?\)\?[mGK]//g"
}
function arg2Decimal () {
printf "%d" $1
}
function stripQuotations () {
sed -e 's/^"//' -e 's/"$//'
}
function ethCoinbase () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m ethCoinbase didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[32m Getting eth_coinbase..."`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[''],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m Coinbase: \e[33m" && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function minerSetEtherbase () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m You must set at least one arguments for walton instance, eg: minerSetEtherbase 1"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
if [ -z $4 ]; then
echo 'No etherbase was set as argument 4, minerSetEtherbase 1 localhost 8545 0xf3faf814cd115ebba078085a3331774b762cf5ee'
return -1
else
ETHERBASE='"'$4'"'
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[32m Setting Etherbase to:\e[32m $ETHERBASE \e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"miner_setEtherbase","params":['$ETHERBASE'],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m Etherbase has been set:\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function minerSetExtra () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m You must set at least one arguments for walton instance, eg: minerSetExtra 1"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
if [ -z $4 ]; then
echo 'No extraData was set as argument 4, minerSetExtra 1 localhost 8545 typeYourExtraData'
return -1
else
EXTRADATA=$4
fi
for ((i=1; i<=$1; i++)); do
EXTRADATA_GPU='"'$EXTRADATA$walton'"'
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Setting extraData as:\e[32m $EXTRADATA_GPU\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"miner_setExtra","params":['$EXTRADATA_GPU'],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m Extradata has been set:\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function adminAddPeer () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e '\e[32m adminAddPeer recieved no arguments, usage: adminAddPeer 1 localhost 8545 enode://<id>@<ip:port>'
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
if [ -z $4 ]; then
echo 'Nothing was set as argument 4, usage: adminAddPeer 1 localhost 8545 enode://<id>@<ip:port>'
return -1
else
PEER_ENODE='"'`echo -n $4 | stripQuotations`'"'
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Adding Peer... as:\e[32m $PEER_ENODE\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_addPeer","params":['$PEER_ENODE'],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m The Peer has been added:\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function netPeerCount () {
walton=0
echo -e -n "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32mdidn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[32m Getting Peer Count..."`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' | ./jq '.result'`
RESULT=`echo -n $CMD | stripQuotations`
OUTPUT2=`echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m net_peerCount:\e[33m " && arg2Decimal $RESULT | tee -a results.txt` && echo $OUTPUT2
walton=$(($walton + 1))
peerCount[$(($i-1))]=$RESULT
done
}
function adminNodeInfoEnode () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32mdidn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting adminNodeInfoEnode...\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":64}' | ./jq '.result' | ./jq '.enode'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function adminNodeInfo () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m adminNodeInfo didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting admin_nodeInfo...\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function adminNodeInfoPorts () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m adminNodeInfoPorts didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting admin_nodeInfo -- Ports...\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":64}' | ./jq -r .[0.] | ./jq .[24].network 2>/dev/null`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function ethBlockNumber () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m ethBlockNumber didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[32m Getting eth_blockNumber..."`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":74}' | ./jq '.result'`
RESULT=`echo -n $CMD | stripQuotations`
OUTPUT2=`echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m eth_blockNumber:\e[33m " && arg2Decimal $RESULT | tee -a results.txt` && echo $OUTPUT2
walton=$(($walton + 1))
done
}
function ethMining () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m ethMining didn't get any arguments -- use at least one argument for the number of peers"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
for ((i=1; i<=$1; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting ming mining status:\e[96m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":64}' | ./jq '.result'`
echo -e -n "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m Mining Status:\e[33m " && RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
walton=$(($walton + 1))
done
}
function adminPeersID () {
unset PEERS
declare -a PEERS
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m adminPeersID didn't get any arguments -- use at least one argument for the number of peers"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
unset peerCount
declare -a peerCount
netPeerCount $1 $2 $3 #needed to set global peer array
walton=0
for ((j=1; j<=$1; j++)); do
unset PEERS
declare -a PEERS
for ((i=0; i<${peerCount[$(($j-1))]}; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting adminPeerID \e[91m$i\e[32m...\e[33m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":64}' | ./jq -r .[0.?] 2> /dev/null | ./jq .[$i].'id' 2> /dev/null`
RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
PEERS[$(($i+$j-1))]=$RESULT
done
walton=$(($walton + 1))
done
}
function adminPeersRemoteIP () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m adminPeersRemoteIP didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
unset peerCount
declare -a peerCount
netPeerCount $1 $2 $3 #needed to set global peer array
walton=0
for ((j=1; j<=$1; j++)); do
unset PEERS
declare -a PEERS
for ((i=0; i<${peerCount[$(($j-1))]}; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting adminPeerRemoteIP \e[91m$i\e[32m...\e[33m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":64}' | ./jq -r .[0.?] 2>/dev/null | ./jq .[$i].'network'.'remoteAddress' 2> /dev/null`
RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
PEERS[$(($i+$j-1))]=$RESULT
done
walton=$(($walton + 1))
done
}
function adminPeersIPENODE () {
walton=0
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m adminPeersIPENODE didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
unset peerCount
declare -a peerCount
netPeerCount $1 $2 $3 #needed to set global peer array
walton=0
for ((j=1; j<=$1; j++)); do
unset PEERS
declare -a PEERS
for ((i=0; i<${peerCount[$(($j-1))]}; i++)); do
OUTPUT=`echo -e "\e[94m[\e[96mwalton:\e[91m$walton\e[94m]\e[95m\e[32m Getting adminPeer IP AND ENODE \e[91m$i\e[32m...\e[33m"`
echo $OUTPUT && echo $OUTPUT | stripColors >> results.txt
CMD=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":64}' | ./jq -r .[0.?] 2>/dev/null | ./jq .[$i].'network'.'remoteAddress' 2> /dev/null`
CMD2=`curl --silent $RPC_SERVER_IP:''$(($RPC_START_PORT + $walton))'' -H $CT -X POST --data '{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":64}' | ./jq -r .[0.?] 2> /dev/null | ./jq .[$i].'id' 2> /dev/null`
RESULT=`echo $CMD | tee -a results.txt` && echo $RESULT
RESULT2=`echo $CMD2 | tee -a results.txt` && echo $RESULT2
PEERS[$(($i+$j-1))]=$RESULT
done
walton=$(($walton + 1))
done
}
function pingPeers() {
echo -e "\e[32m"
if [ -z $1 ]; then
echo -e "\e[32m pingPeers didn't get any arguments -- use at least one argument for the number of instances"
return -1
fi
if [ -z $2 ]; then
RPC_SERVER_IP=127.0.0.1
echo -e "\e[32mSetting IP to 127.0.0.1..."
else
RPC_SERVER_IP=$2
fi
if [ -z $3 ]; then
RPC_START_PORT=8545
echo "Setting RPC Start Port To: 8545..."
else
RPC_START_PORT=$3
fi
walton=0
adminPeersRemoteIP $1 $2 $3
for PEER in ${PEERS[@]}; do
printf "%-8s\n" $grn ${PEER} $yel| tee results.txt
ping -4 -w 750 -n 2 $(echo -n ${PEER} | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') | tail -1 | awk '{print $9}' | cut -d '/' -f 2
done #| column
}
################################[USER OPTIONS]#####################################/
function wMain() {
enumRPCPorts $1
echo -e "\e[97mIPv4 LAN ADDRESS(ES): "
ipconfig | grep "IPv4" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
echo -e "\e[32mRunning on RPC PORTS: '${RPC_PORTS[*]}'"
minerSetEtherbase ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]} ${WALLET[$1]}
minerSetExtra ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]} ${EXTRA_DATA[$1]}
adminNodeInfoEnode 1 ${IP[$1]} ${RPC_PORTS[0]} 1> /dev/null
ENODE_ZEROES[$1]=${RESULT}
#for ((k=0;k<$1+1;k++)); do
#adminAddPeer 1 ${IP[$1]} ${RPC_PORT_START[$1]} ${ENODE_ZEROES[$1]}
adminAddPeer ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]} ${ENODE_ZEROES[$1]}
#done
adminAddPeer ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]} enode://284ab3de33d9442dc4de37fe843bc5490386f3c025216729d3ede3234140d63f7cb1b0cec9fad545adc669ad982cd7e5c92c109a203cef3e751a1ab056584446@78.129.218.56:30303
#adminAddPeer ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]}
ethMining ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]}
ethBlockNumber ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]}
adminNodeInfoEnode ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]}
pingPeers ${NUMBER_OF_WALTONS[$1]} ${IP[$1]} ${RPC_PORT_START[$1]}
#adminPeersID $NUMBER_OF_WALTONS $IP $RPC_PORT_START #stand alone adminPeersID example.
#ethCoinbase $NUMBER_OF_WALTONS $IP $RPC_PORT_START #stand alone coinbase example.
#adminPeersRemoteIP $NUMBER_OF_WALTONS $IP $RPC_PORT_START #adminPeersRemoteIP stand alone example.
#netPeerCount $NUMBER_OF_WALTONS $IP $RPC_PORT_START #netPeerCount stand alone example.
#IPv6=$(curl --silent icanhazip.com) && echo "$IPv6"
echo -e -n "\e[97m"
}
################################[USER OPTIONS]#####################################/
#RIGLOOP THROUGH wMain()
for ((r=0;r<$NUM_OF_RIGS;r++)); do
wMain $r
done