mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-29 00:57:17 -04:00
Use long instead of int for bytes in statistics
This commit is contained in:
parent
1335238591
commit
1dae1dd096
4 changed files with 18 additions and 16 deletions
|
@ -152,7 +152,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
nodeAddress -> onionAddress.setText(nodeAddress == null ? "Not known yet..." : p2PService.getAddress().getFullAddress()));
|
nodeAddress -> onionAddress.setText(nodeAddress == null ? "Not known yet..." : p2PService.getAddress().getFullAddress()));
|
||||||
numP2PPeersSubscription = EasyBind.subscribe(p2PService.getNumConnectedPeers(), numPeers -> updateP2PTable());
|
numP2PPeersSubscription = EasyBind.subscribe(p2PService.getNumConnectedPeers(), numPeers -> updateP2PTable());
|
||||||
totalTraffic.textProperty().bind(EasyBind.combine(Statistic.totalSentBytesProperty(), Statistic.totalReceivedBytesProperty(),
|
totalTraffic.textProperty().bind(EasyBind.combine(Statistic.totalSentBytesProperty(), Statistic.totalReceivedBytesProperty(),
|
||||||
(sent, received) -> "Sent: " + formatter.formatBytes((int) sent) + ", received: " + formatter.formatBytes((int) received)));
|
(sent, received) -> "Sent: " + formatter.formatBytes((long) sent) + ", received: " + formatter.formatBytes((long) received)));
|
||||||
|
|
||||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||||
tableView.setItems(sortedList);
|
tableView.setItems(sortedList);
|
||||||
|
|
|
@ -55,9 +55,9 @@ public class P2pNetworkListItem {
|
||||||
this.statistic = connection.getStatistic();
|
this.statistic = connection.getStatistic();
|
||||||
|
|
||||||
sentBytesSubscription = EasyBind.subscribe(statistic.sentBytesProperty(),
|
sentBytesSubscription = EasyBind.subscribe(statistic.sentBytesProperty(),
|
||||||
e -> sentBytes.set(formatter.formatBytes((int) e)));
|
e -> sentBytes.set(formatter.formatBytes((long) e)));
|
||||||
receivedBytesSubscription = EasyBind.subscribe(statistic.receivedBytesProperty(),
|
receivedBytesSubscription = EasyBind.subscribe(statistic.receivedBytesProperty(),
|
||||||
e -> receivedBytes.set(formatter.formatBytes((int) e)));
|
e -> receivedBytes.set(formatter.formatBytes((long) e)));
|
||||||
onionAddressSubscription = EasyBind.subscribe(connection.peersNodeAddressProperty(),
|
onionAddressSubscription = EasyBind.subscribe(connection.peersNodeAddressProperty(),
|
||||||
nodeAddress -> onionAddress.set(nodeAddress != null ? nodeAddress.getFullAddress() : "Not known yet"));
|
nodeAddress -> onionAddress.set(nodeAddress != null ? nodeAddress.getFullAddress() : "Not known yet"));
|
||||||
roundTripTimeSubscription = EasyBind.subscribe(statistic.roundTripTimeProperty(),
|
roundTripTimeSubscription = EasyBind.subscribe(statistic.roundTripTimeProperty(),
|
||||||
|
|
|
@ -489,7 +489,7 @@ public class BSFormatter {
|
||||||
return isOfferer ? "Seller (offerer)" : "Buyer (taker)";
|
return isOfferer ? "Seller (offerer)" : "Buyer (taker)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatBytes(int bytes) {
|
public String formatBytes(long bytes) {
|
||||||
double kb = 1024;
|
double kb = 1024;
|
||||||
double mb = kb * kb;
|
double mb = kb * kb;
|
||||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||||
|
|
|
@ -3,7 +3,9 @@ package io.bitsquare.p2p.network;
|
||||||
import io.bitsquare.common.UserThread;
|
import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.p2p.Message;
|
import io.bitsquare.p2p.Message;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.LongProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -19,22 +21,22 @@ public class Statistic {
|
||||||
// Static
|
// Static
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private final static IntegerProperty totalSentBytes = new SimpleIntegerProperty(0);
|
private final static LongProperty totalSentBytes = new SimpleLongProperty(0);
|
||||||
private final static IntegerProperty totalReceivedBytes = new SimpleIntegerProperty(0);
|
private final static LongProperty totalReceivedBytes = new SimpleLongProperty(0);
|
||||||
|
|
||||||
public static int getTotalSentBytes() {
|
public static long getTotalSentBytes() {
|
||||||
return totalSentBytes.get();
|
return totalSentBytes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntegerProperty totalSentBytesProperty() {
|
public static LongProperty totalSentBytesProperty() {
|
||||||
return totalSentBytes;
|
return totalSentBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTotalReceivedBytes() {
|
public static long getTotalReceivedBytes() {
|
||||||
return totalReceivedBytes.get();
|
return totalReceivedBytes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntegerProperty totalReceivedBytesProperty() {
|
public static LongProperty totalReceivedBytesProperty() {
|
||||||
return totalReceivedBytes;
|
return totalReceivedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +47,8 @@ public class Statistic {
|
||||||
|
|
||||||
private final Date creationDate;
|
private final Date creationDate;
|
||||||
private long lastActivityTimestamp = System.currentTimeMillis();
|
private long lastActivityTimestamp = System.currentTimeMillis();
|
||||||
private final IntegerProperty sentBytes = new SimpleIntegerProperty(0);
|
private final LongProperty sentBytes = new SimpleLongProperty(0);
|
||||||
private final IntegerProperty receivedBytes = new SimpleIntegerProperty(0);
|
private final LongProperty receivedBytes = new SimpleLongProperty(0);
|
||||||
private final Map<String, Integer> receivedMessages = new ConcurrentHashMap<>();
|
private final Map<String, Integer> receivedMessages = new ConcurrentHashMap<>();
|
||||||
private final Map<String, Integer> sentMessages = new ConcurrentHashMap<>();
|
private final Map<String, Integer> sentMessages = new ConcurrentHashMap<>();
|
||||||
private final IntegerProperty roundTripTime = new SimpleIntegerProperty(0);
|
private final IntegerProperty roundTripTime = new SimpleIntegerProperty(0);
|
||||||
|
@ -117,19 +119,19 @@ public class Statistic {
|
||||||
return System.currentTimeMillis() - lastActivityTimestamp;
|
return System.currentTimeMillis() - lastActivityTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSentBytes() {
|
public long getSentBytes() {
|
||||||
return sentBytes.get();
|
return sentBytes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntegerProperty sentBytesProperty() {
|
public LongProperty sentBytesProperty() {
|
||||||
return sentBytes;
|
return sentBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReceivedBytes() {
|
public long getReceivedBytes() {
|
||||||
return receivedBytes.get();
|
return receivedBytes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntegerProperty receivedBytesProperty() {
|
public LongProperty receivedBytesProperty() {
|
||||||
return receivedBytes;
|
return receivedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue