forked from Qortal/qortal
Merge pull request #39 from szisti/networking
Code formatting, connection age, and logging changes for networking
This commit is contained in:
commit
5a84016a91
24
pom.xml
24
pom.xml
@ -326,30 +326,6 @@
|
|||||||
<skipTests>${skipTests}</skipTests>
|
<skipTests>${skipTests}</skipTests>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.jacoco</groupId>
|
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
|
||||||
<version>0.8.7</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>prepare-agent</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>generate-code-coverage-report</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>org.bouncycastle.*</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -1,61 +1,74 @@
|
|||||||
package org.qortal.api.model;
|
package org.qortal.api.model;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
|
|
||||||
import org.qortal.data.network.PeerChainTipData;
|
import org.qortal.data.network.PeerChainTipData;
|
||||||
import org.qortal.data.network.PeerData;
|
import org.qortal.data.network.PeerData;
|
||||||
import org.qortal.network.Handshake;
|
import org.qortal.network.Handshake;
|
||||||
import org.qortal.network.Peer;
|
import org.qortal.network.Peer;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ConnectedPeer {
|
public class ConnectedPeer {
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
INBOUND,
|
INBOUND,
|
||||||
OUTBOUND;
|
OUTBOUND;
|
||||||
}
|
}
|
||||||
public Direction direction;
|
|
||||||
public Handshake handshakeStatus;
|
|
||||||
public Long lastPing;
|
|
||||||
public Long connectedWhen;
|
|
||||||
public Long peersConnectedWhen;
|
|
||||||
|
|
||||||
public String address;
|
public Direction direction;
|
||||||
public String version;
|
public Handshake handshakeStatus;
|
||||||
|
public Long lastPing;
|
||||||
|
public Long connectedWhen;
|
||||||
|
public Long peersConnectedWhen;
|
||||||
|
|
||||||
public String nodeId;
|
public String address;
|
||||||
|
public String version;
|
||||||
|
|
||||||
public Integer lastHeight;
|
public String nodeId;
|
||||||
@Schema(example = "base58")
|
|
||||||
public byte[] lastBlockSignature;
|
|
||||||
public Long lastBlockTimestamp;
|
|
||||||
|
|
||||||
protected ConnectedPeer() {
|
public Integer lastHeight;
|
||||||
}
|
@Schema(example = "base58")
|
||||||
|
public byte[] lastBlockSignature;
|
||||||
|
public Long lastBlockTimestamp;
|
||||||
|
public UUID connectionId;
|
||||||
|
public String age;
|
||||||
|
|
||||||
public ConnectedPeer(Peer peer) {
|
protected ConnectedPeer() {
|
||||||
this.direction = peer.isOutbound() ? Direction.OUTBOUND : Direction.INBOUND;
|
}
|
||||||
this.handshakeStatus = peer.getHandshakeStatus();
|
|
||||||
this.lastPing = peer.getLastPing();
|
|
||||||
|
|
||||||
PeerData peerData = peer.getPeerData();
|
public ConnectedPeer(Peer peer) {
|
||||||
this.connectedWhen = peer.getConnectionTimestamp();
|
this.direction = peer.isOutbound() ? Direction.OUTBOUND : Direction.INBOUND;
|
||||||
this.peersConnectedWhen = peer.getPeersConnectionTimestamp();
|
this.handshakeStatus = peer.getHandshakeStatus();
|
||||||
|
this.lastPing = peer.getLastPing();
|
||||||
|
|
||||||
this.address = peerData.getAddress().toString();
|
PeerData peerData = peer.getPeerData();
|
||||||
|
this.connectedWhen = peer.getConnectionTimestamp();
|
||||||
|
this.peersConnectedWhen = peer.getPeersConnectionTimestamp();
|
||||||
|
|
||||||
this.version = peer.getPeersVersionString();
|
this.address = peerData.getAddress().toString();
|
||||||
this.nodeId = peer.getPeersNodeId();
|
|
||||||
|
|
||||||
PeerChainTipData peerChainTipData = peer.getChainTipData();
|
this.version = peer.getPeersVersionString();
|
||||||
if (peerChainTipData != null) {
|
this.nodeId = peer.getPeersNodeId();
|
||||||
this.lastHeight = peerChainTipData.getLastHeight();
|
this.connectionId = peer.getPeerConnectionId();
|
||||||
this.lastBlockSignature = peerChainTipData.getLastBlockSignature();
|
if (peer.getConnectionEstablishedTime() > 0) {
|
||||||
this.lastBlockTimestamp = peerChainTipData.getLastBlockTimestamp();
|
long age = (System.currentTimeMillis() - peer.getConnectionEstablishedTime());
|
||||||
}
|
long minutes = TimeUnit.MILLISECONDS.toMinutes(age);
|
||||||
}
|
long seconds = TimeUnit.MILLISECONDS.toSeconds(age) - TimeUnit.MINUTES.toSeconds(minutes);
|
||||||
|
this.age = String.format("%dm %ds", minutes, seconds);
|
||||||
|
} else {
|
||||||
|
this.age = "connecting...";
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerChainTipData peerChainTipData = peer.getChainTipData();
|
||||||
|
if (peerChainTipData != null) {
|
||||||
|
this.lastHeight = peerChainTipData.getLastHeight();
|
||||||
|
this.lastBlockSignature = peerChainTipData.getLastBlockSignature();
|
||||||
|
this.lastBlockTimestamp = peerChainTipData.getLastBlockTimestamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user