forked from DeepCoin/nxt-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nxt$Peer.java
748 lines (682 loc) · 23.8 KB
/
Nxt$Peer.java
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.NoRouteToHostException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
class Nxt$Peer
implements Comparable<Peer>
{
static final int STATE_NONCONNECTED = 0;
static final int STATE_CONNECTED = 1;
static final int STATE_DISCONNECTED = 2;
final int index;
String platform;
String announcedAddress;
boolean shareAddress;
String hallmark;
long accountId;
int weight;
int date;
long adjustedWeight;
String application;
String version;
long blacklistingTime;
int state;
long downloadedVolume;
long uploadedVolume;
Nxt$Peer(String announcedAddress, int index)
{
this.announcedAddress = announcedAddress;
this.index = index;
}
static Peer addPeer(String address, String announcedAddress)
{
try
{
new URL("http://" + address);
}
catch (MalformedURLException e)
{
Nxt.logDebugMessage("malformed peer address " + address, e);
return null;
}
try
{
new URL("http://" + announcedAddress);
}
catch (MalformedURLException e)
{
Nxt.logDebugMessage("malformed peer announced address " + announcedAddress, e);
announcedAddress = "";
}
if ((address.equals("localhost")) || (address.equals("127.0.0.1")) || (address.equals("0:0:0:0:0:0:0:1"))) {
return null;
}
if ((Nxt.myAddress != null) && (Nxt.myAddress.length() > 0) && (Nxt.myAddress.equals(announcedAddress))) {
return null;
}
Peer peer = (Peer)Nxt.peers.get(announcedAddress.length() > 0 ? announcedAddress : address);
if (peer == null)
{
peer = new Peer(announcedAddress, Nxt.peerCounter.incrementAndGet());
Nxt.peers.put(announcedAddress.length() > 0 ? announcedAddress : address, peer);
}
return peer;
}
boolean analyzeHallmark(String realHost, String hallmark)
{
if (hallmark == null) {
return true;
}
try
{
byte[] hallmarkBytes;
try
{
hallmarkBytes = Nxt.convert(hallmark);
}
catch (NumberFormatException e)
{
return false;
}
ByteBuffer buffer = ByteBuffer.wrap(hallmarkBytes);
buffer.order(ByteOrder.LITTLE_ENDIAN);
byte[] publicKey = new byte[32];
buffer.get(publicKey);
int hostLength = buffer.getShort();
byte[] hostBytes = new byte[hostLength];
buffer.get(hostBytes);
String host = new String(hostBytes, "UTF-8");
if ((host.length() > 100) || (!host.equals(realHost))) {
return false;
}
int weight = buffer.getInt();
if ((weight <= 0) || (weight > 1000000000L)) {
return false;
}
int date = buffer.getInt();
buffer.get();
byte[] signature = new byte[64];
buffer.get(signature);
byte[] data = new byte[hallmarkBytes.length - 64];
System.arraycopy(hallmarkBytes, 0, data, 0, data.length);
if (Nxt.Crypto.verify(signature, data, publicKey))
{
this.hallmark = hallmark;
long accountId = Nxt.Account.getId(publicKey);
LinkedList<Peer> groupedPeers = new LinkedList();
int validDate = 0;
this.accountId = accountId;
this.weight = weight;
this.date = date;
for (Peer peer : Nxt.peers.values()) {
if (peer.accountId == accountId)
{
groupedPeers.add(peer);
if (peer.date > validDate) {
validDate = peer.date;
}
}
}
long totalWeight = 0L;
for (Peer peer : groupedPeers) {
if (peer.date == validDate)
{
totalWeight += peer.weight;
}
else
{
peer.adjustedWeight = 0L;
peer.updateWeight();
}
}
for (Peer peer : groupedPeers)
{
peer.adjustedWeight = (1000000000L * peer.weight / totalWeight);
peer.updateWeight();
}
return true;
}
}
catch (RuntimeException|UnsupportedEncodingException e)
{
Nxt.logDebugMessage("Failed to analyze hallmark for peer " + realHost, e);
}
return false;
}
void blacklist()
{
this.blacklistingTime = System.currentTimeMillis();
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray removedKnownPeers = new JSONArray();
JSONObject removedKnownPeer = new JSONObject();
removedKnownPeer.put("index", Integer.valueOf(this.index));
removedKnownPeers.add(removedKnownPeer);
response.put("removedKnownPeers", removedKnownPeers);
JSONArray addedBlacklistedPeers = new JSONArray();
JSONObject addedBlacklistedPeer = new JSONObject();
addedBlacklistedPeer.put("index", Integer.valueOf(this.index));
addedBlacklistedPeer.put("announcedAddress", this.announcedAddress.length() > 30 ? this.announcedAddress.substring(0, 30) + "..." : this.announcedAddress);
for (String wellKnownPeer : Nxt.wellKnownPeers) {
if (this.announcedAddress.equals(wellKnownPeer))
{
addedBlacklistedPeer.put("wellKnown", Boolean.valueOf(true));
break;
}
}
addedBlacklistedPeers.add(addedBlacklistedPeer);
response.put("addedBlacklistedPeers", addedBlacklistedPeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
public int compareTo(Peer o)
{
long weight = getWeight();long weight2 = o.getWeight();
if (weight > weight2) {
return -1;
}
if (weight < weight2) {
return 1;
}
return this.index - o.index;
}
void connect()
{
JSONObject request = new JSONObject();
request.put("requestType", "getInfo");
if ((Nxt.myAddress != null) && (Nxt.myAddress.length() > 0)) {
request.put("announcedAddress", Nxt.myAddress);
}
if ((Nxt.myHallmark != null) && (Nxt.myHallmark.length() > 0)) {
request.put("hallmark", Nxt.myHallmark);
}
request.put("application", "NRS");
request.put("version", "0.5.7");
request.put("platform", Nxt.myPlatform);
request.put("scheme", Nxt.myScheme);
request.put("port", Integer.valueOf(Nxt.myPort));
request.put("shareAddress", Boolean.valueOf(Nxt.shareMyAddress));
JSONObject response = send(request);
if (response != null)
{
this.application = ((String)response.get("application"));
this.version = ((String)response.get("version"));
this.platform = ((String)response.get("platform"));
this.shareAddress = Boolean.TRUE.equals(response.get("shareAddress"));
if (analyzeHallmark(this.announcedAddress, (String)response.get("hallmark"))) {
setState(1);
}
}
}
void deactivate()
{
if (this.state == 1) {
disconnect();
}
setState(0);
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray removedActivePeers = new JSONArray();
JSONObject removedActivePeer = new JSONObject();
removedActivePeer.put("index", Integer.valueOf(this.index));
removedActivePeers.add(removedActivePeer);
response.put("removedActivePeers", removedActivePeers);
if (this.announcedAddress.length() > 0)
{
JSONArray addedKnownPeers = new JSONArray();
JSONObject addedKnownPeer = new JSONObject();
addedKnownPeer.put("index", Integer.valueOf(this.index));
addedKnownPeer.put("announcedAddress", this.announcedAddress.length() > 30 ? this.announcedAddress.substring(0, 30) + "..." : this.announcedAddress);
for (String wellKnownPeer : Nxt.wellKnownPeers) {
if (this.announcedAddress.equals(wellKnownPeer))
{
addedKnownPeer.put("wellKnown", Boolean.valueOf(true));
break;
}
}
addedKnownPeers.add(addedKnownPeer);
response.put("addedKnownPeers", addedKnownPeers);
}
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
void disconnect()
{
setState(2);
}
static Peer getAnyPeer(int state, boolean applyPullThreshold)
{
List<Peer> selectedPeers = new ArrayList();
for (Peer peer : Nxt.peers.values()) {
if ((peer.blacklistingTime <= 0L) && (peer.state == state) && (peer.announcedAddress.length() > 0) && ((!applyPullThreshold) || (!Nxt.enableHallmarkProtection) || (peer.getWeight() >= Nxt.pullThreshold))) {
selectedPeers.add(peer);
}
}
long hit;
if (selectedPeers.size() > 0)
{
long totalWeight = 0L;
for (Peer peer : selectedPeers)
{
long weight = peer.getWeight();
if (weight == 0L) {
weight = 1L;
}
totalWeight += weight;
}
hit = ThreadLocalRandom.current().nextLong(totalWeight);
for (Peer peer : selectedPeers)
{
long weight = peer.getWeight();
if (weight == 0L) {
weight = 1L;
}
if (hit -= weight < 0L) {
return peer;
}
}
}
return null;
}
static int getNumberOfConnectedPublicPeers()
{
int numberOfConnectedPeers = 0;
for (Peer peer : Nxt.peers.values()) {
if ((peer.state == 1) && (peer.announcedAddress.length() > 0)) {
numberOfConnectedPeers++;
}
}
return numberOfConnectedPeers;
}
int getWeight()
{
if (this.accountId == 0L) {
return 0;
}
Nxt.Account account = (Nxt.Account)Nxt.accounts.get(Long.valueOf(this.accountId));
if (account == null) {
return 0;
}
return (int)(this.adjustedWeight * (account.getBalance() / 100L) / 1000000000L);
}
String getSoftware()
{
StringBuilder buf = new StringBuilder();
buf.append(this.application == null ? "?" : this.application.substring(0, Math.min(this.application.length(), 10)));
buf.append(" (");
buf.append(this.version == null ? "?" : this.version.substring(0, Math.min(this.version.length(), 10)));
buf.append(")").append(" @ ");
buf.append(this.platform == null ? "?" : this.platform.substring(0, Math.min(this.platform.length(), 12)));
return buf.toString();
}
void removeBlacklistedStatus()
{
setState(0);
this.blacklistingTime = 0L;
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray removedBlacklistedPeers = new JSONArray();
JSONObject removedBlacklistedPeer = new JSONObject();
removedBlacklistedPeer.put("index", Integer.valueOf(this.index));
removedBlacklistedPeers.add(removedBlacklistedPeer);
response.put("removedBlacklistedPeers", removedBlacklistedPeers);
JSONArray addedKnownPeers = new JSONArray();
JSONObject addedKnownPeer = new JSONObject();
addedKnownPeer.put("index", Integer.valueOf(this.index));
addedKnownPeer.put("announcedAddress", this.announcedAddress.length() > 30 ? this.announcedAddress.substring(0, 30) + "..." : this.announcedAddress);
for (String wellKnownPeer : Nxt.wellKnownPeers) {
if (this.announcedAddress.equals(wellKnownPeer))
{
addedKnownPeer.put("wellKnown", Boolean.valueOf(true));
break;
}
}
addedKnownPeers.add(addedKnownPeer);
response.put("addedKnownPeers", addedKnownPeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
void removePeer()
{
Nxt.peers.values().remove(this);
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray removedKnownPeers = new JSONArray();
JSONObject removedKnownPeer = new JSONObject();
removedKnownPeer.put("index", Integer.valueOf(this.index));
removedKnownPeers.add(removedKnownPeer);
response.put("removedKnownPeers", removedKnownPeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
static void sendToSomePeers(JSONObject request)
{
int successful = 0;
List<Future<JSONObject>> expectedResponses = new ArrayList();
for (Peer peer : Nxt.peers.values()) {
if ((!Nxt.enableHallmarkProtection) || (peer.getWeight() >= Nxt.pushThreshold))
{
if ((peer.blacklistingTime == 0L) && (peer.state == 1) && (peer.announcedAddress.length() > 0))
{
Future<JSONObject> futureResponse = Nxt.sendToPeersService.submit(new Nxt.Peer.1(peer, request));
expectedResponses.add(futureResponse);
}
if (expectedResponses.size() >= Nxt.sendToPeersLimit - successful)
{
for (Future<JSONObject> future : expectedResponses) {
try
{
JSONObject response = (JSONObject)future.get();
if ((response != null) && (response.get("error") == null)) {
successful++;
}
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
catch (ExecutionException e)
{
Nxt.logDebugMessage("Error in sendToSomePeers", e);
}
}
expectedResponses.clear();
}
if (successful >= Nxt.sendToPeersLimit) {
return;
}
}
}
}
JSONObject send(JSONObject request)
{
String log = null;
boolean showLog = false;
HttpURLConnection connection = null;
JSONObject response;
try
{
if (Nxt.communicationLoggingMask != 0) {
log = "\"" + this.announcedAddress + "\": " + request.toString();
}
request.put("protocol", Integer.valueOf(1));
URL url = new URL("http://" + this.announcedAddress + (new URL("http://" + this.announcedAddress).getPort() < 0 ? ":7874" : "") + "/nxt");
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setConnectTimeout(Nxt.connectTimeout);
connection.setReadTimeout(Nxt.readTimeout);
Nxt.CountingOutputStream cos = new Nxt.CountingOutputStream(connection.getOutputStream());
Writer writer = new BufferedWriter(new OutputStreamWriter(cos, "UTF-8"));Throwable localThrowable4 = null;
try
{
request.writeJSONString(writer);
}
catch (Throwable localThrowable1)
{
localThrowable4 = localThrowable1;throw localThrowable1;
}
finally
{
if (writer != null) {
if (localThrowable4 != null) {
try
{
writer.close();
}
catch (Throwable x2)
{
localThrowable4.addSuppressed(x2);
}
} else {
writer.close();
}
}
}
updateUploadedVolume(cos.getCount());
if (connection.getResponseCode() == 200)
{
int numberOfBytes;
JSONObject response;
if ((Nxt.communicationLoggingMask & 0x4) != 0)
{
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[65536];
InputStream inputStream = connection.getInputStream();x2 = null;
try
{
while ((numberOfBytes = inputStream.read(buffer)) > 0) {
byteArrayOutputStream.write(buffer, 0, numberOfBytes);
}
}
catch (Throwable localThrowable2)
{
x2 = localThrowable2;throw localThrowable2;
}
finally
{
if (inputStream != null) {
if (x2 != null) {
try
{
inputStream.close();
}
catch (Throwable x2)
{
x2.addSuppressed(x2);
}
} else {
inputStream.close();
}
}
}
String responseValue = byteArrayOutputStream.toString("UTF-8");
log = log + " >>> " + responseValue;
showLog = true;
updateDownloadedVolume(responseValue.getBytes("UTF-8").length);
response = (JSONObject)JSONValue.parse(responseValue);
}
else
{
Nxt.CountingInputStream cis = new Nxt.CountingInputStream(connection.getInputStream());
Object reader = new BufferedReader(new InputStreamReader(cis, "UTF-8"));numberOfBytes = null;
try
{
response = (JSONObject)JSONValue.parse((Reader)reader);
}
catch (Throwable localThrowable5)
{
JSONObject response;
numberOfBytes = localThrowable5;throw localThrowable5;
}
finally
{
if (reader != null) {
if (numberOfBytes != null) {
try
{
((Reader)reader).close();
}
catch (Throwable x2)
{
numberOfBytes.addSuppressed(x2);
}
} else {
((Reader)reader).close();
}
}
}
updateDownloadedVolume(cis.getCount());
}
}
else
{
if ((Nxt.communicationLoggingMask & 0x2) != 0)
{
log = log + " >>> Peer responded with HTTP " + connection.getResponseCode() + " code!";
showLog = true;
}
disconnect();
response = null;
}
}
catch (RuntimeException|IOException e)
{
if ((!(e instanceof ConnectException)) && (!(e instanceof UnknownHostException)) && (!(e instanceof NoRouteToHostException)) && (!(e instanceof SocketTimeoutException)) && (!(e instanceof SocketException))) {
Nxt.logDebugMessage("Error sending JSON request", e);
}
if ((Nxt.communicationLoggingMask & 0x1) != 0)
{
log = log + " >>> " + e.toString();
showLog = true;
}
if (this.state == 0) {
blacklist();
} else {
disconnect();
}
response = null;
}
if (showLog) {
Nxt.logMessage(log + "\n");
}
if (connection != null) {
connection.disconnect();
}
return response;
}
void setState(int state)
{
JSONObject response;
JSONObject response;
if ((this.state == 0) && (state != 0))
{
response = new JSONObject();
response.put("response", "processNewData");
if (this.announcedAddress.length() > 0)
{
JSONArray removedKnownPeers = new JSONArray();
JSONObject removedKnownPeer = new JSONObject();
removedKnownPeer.put("index", Integer.valueOf(this.index));
removedKnownPeers.add(removedKnownPeer);
response.put("removedKnownPeers", removedKnownPeers);
}
JSONArray addedActivePeers = new JSONArray();
JSONObject addedActivePeer = new JSONObject();
addedActivePeer.put("index", Integer.valueOf(this.index));
if (state == 2) {
addedActivePeer.put("disconnected", Boolean.valueOf(true));
}
for (Map.Entry<String, Peer> peerEntry : Nxt.peers.entrySet()) {
if (peerEntry.getValue() == this)
{
addedActivePeer.put("address", ((String)peerEntry.getKey()).length() > 30 ? ((String)peerEntry.getKey()).substring(0, 30) + "..." : (String)peerEntry.getKey());
break;
}
}
addedActivePeer.put("announcedAddress", this.announcedAddress.length() > 30 ? this.announcedAddress.substring(0, 30) + "..." : this.announcedAddress);
addedActivePeer.put("weight", Integer.valueOf(getWeight()));
addedActivePeer.put("downloaded", Long.valueOf(this.downloadedVolume));
addedActivePeer.put("uploaded", Long.valueOf(this.uploadedVolume));
addedActivePeer.put("software", getSoftware());
for (String wellKnownPeer : Nxt.wellKnownPeers) {
if (this.announcedAddress.equals(wellKnownPeer))
{
addedActivePeer.put("wellKnown", Boolean.valueOf(true));
break;
}
}
addedActivePeers.add(addedActivePeer);
response.put("addedActivePeers", addedActivePeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
else if ((this.state != 0) && (state != 0))
{
response = new JSONObject();
response.put("response", "processNewData");
JSONArray changedActivePeers = new JSONArray();
JSONObject changedActivePeer = new JSONObject();
changedActivePeer.put("index", Integer.valueOf(this.index));
changedActivePeer.put(state == 1 ? "connected" : "disconnected", Boolean.valueOf(true));
changedActivePeers.add(changedActivePeer);
response.put("changedActivePeers", changedActivePeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
this.state = state;
}
void updateDownloadedVolume(long volume)
{
this.downloadedVolume += volume;
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray changedActivePeers = new JSONArray();
JSONObject changedActivePeer = new JSONObject();
changedActivePeer.put("index", Integer.valueOf(this.index));
changedActivePeer.put("downloaded", Long.valueOf(this.downloadedVolume));
changedActivePeers.add(changedActivePeer);
response.put("changedActivePeers", changedActivePeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
void updateUploadedVolume(long volume)
{
this.uploadedVolume += volume;
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray changedActivePeers = new JSONArray();
JSONObject changedActivePeer = new JSONObject();
changedActivePeer.put("index", Integer.valueOf(this.index));
changedActivePeer.put("uploaded", Long.valueOf(this.uploadedVolume));
changedActivePeers.add(changedActivePeer);
response.put("changedActivePeers", changedActivePeers);
for (Nxt.User user : Nxt.users.values()) {
user.send(response);
}
}
void updateWeight()
{
JSONObject response = new JSONObject();
response.put("response", "processNewData");
JSONArray changedActivePeers = new JSONArray();
JSONObject changedActivePeer = new JSONObject();
changedActivePeer.put("index", Integer.valueOf(this.index));
changedActivePeer.put("weight", Integer.valueOf(getWeight()));