3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 02:05:53 +00:00

Peer: Add a convenience accessor

This commit is contained in:
Mike Hearn 2014-12-17 18:58:16 +01:00
parent 9025a65334
commit 54edb541a2

View File

@ -155,9 +155,6 @@ public class PeerAddress extends ChildMessage {
port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]); port = ((0xFF & payload[cursor++]) << 8) | (0xFF & payload[cursor++]);
} }
/* (non-Javadoc)
* @see Message#getMessageSize()
*/
@Override @Override
public int getMessageSize() { public int getMessageSize() {
// The 4 byte difference is the uint32 timestamp that was introduced in version 31402 // The 4 byte difference is the uint32 timestamp that was introduced in version 31402
@ -165,72 +162,51 @@ public class PeerAddress extends ChildMessage {
return length; return length;
} }
/**
* @return the addr
*/
public InetAddress getAddr() { public InetAddress getAddr() {
maybeParse(); maybeParse();
return addr; return addr;
} }
public InetSocketAddress getSocketAddress() {
return new InetSocketAddress(getAddr(), getPort());
}
/**
* @param addr the addr to set
*/
public void setAddr(InetAddress addr) { public void setAddr(InetAddress addr) {
unCache(); unCache();
this.addr = addr; this.addr = addr;
} }
/**
* @return the port
*/
public int getPort() { public int getPort() {
maybeParse(); maybeParse();
return port; return port;
} }
/**
* @param port the port to set
*/
public void setPort(int port) { public void setPort(int port) {
unCache(); unCache();
this.port = port; this.port = port;
} }
/**
* @return the services
*/
public BigInteger getServices() { public BigInteger getServices() {
maybeParse(); maybeParse();
return services; return services;
} }
/**
* @param services the services to set
*/
public void setServices(BigInteger services) { public void setServices(BigInteger services) {
unCache(); unCache();
this.services = services; this.services = services;
} }
/**
* @return the time
*/
public long getTime() { public long getTime() {
maybeParse(); maybeParse();
return time; return time;
} }
/**
* @param time the time to set
*/
public void setTime(long time) { public void setTime(long time) {
unCache(); unCache();
this.time = time; this.time = time;