3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 06:44:16 +00:00

FindBugs: make random an object field rather than a disposable temporary.

This commit is contained in:
Mike Hearn 2012-12-26 18:57:03 +00:00
parent bf3a8dc085
commit 4e0f5d8903

View File

@ -67,6 +67,8 @@ public class TCPNetworkConnection implements NetworkConnection {
private Channel channel; private Channel channel;
private NetworkHandler handler; private NetworkHandler handler;
// For ping nonces.
private Random random = new Random();
/** /**
* Construct a network connection with the given params and version. If you use this constructor you need to set * Construct a network connection with the given params and version. If you use this constructor you need to set
@ -177,8 +179,9 @@ public class TCPNetworkConnection implements NetworkConnection {
public void ping() throws IOException { public void ping() throws IOException {
// pong/nonce messages were added to any protocol version greater than 60000 // pong/nonce messages were added to any protocol version greater than 60000
if (versionMessage.clientVersion > 60000) if (versionMessage.clientVersion > 60000) {
write(channel, new Ping(new Random().nextLong())); write(channel, new Ping(random.nextLong()));
}
else else
write(channel, new Ping()); write(channel, new Ping());
} }