mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Fix Java 6 compatibility.
This commit is contained in:
parent
0f124b9ef4
commit
4dc3392719
@ -17,6 +17,7 @@
|
|||||||
package com.google.bitcoin.core;
|
package com.google.bitcoin.core;
|
||||||
|
|
||||||
import com.google.bitcoin.params.MainNetParams;
|
import com.google.bitcoin.params.MainNetParams;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -100,7 +101,7 @@ public class PeerAddress extends ChildMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PeerAddress localhost(NetworkParameters params) {
|
public static PeerAddress localhost(NetworkParameters params) {
|
||||||
return new PeerAddress(InetAddress.getLoopbackAddress(), params.getPort());
|
return new PeerAddress(InetAddresses.forString("127.0.0.1"), params.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,6 +34,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.common.util.concurrent.*;
|
import com.google.common.util.concurrent.*;
|
||||||
@ -706,9 +707,13 @@ public class PeerGroup extends AbstractExecutionThreadService implements Transac
|
|||||||
// Do a fast blocking connect to see if anything is listening.
|
// Do a fast blocking connect to see if anything is listening.
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket();
|
Socket socket = new Socket();
|
||||||
socket.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), params.getPort()), vConnectTimeoutMillis);
|
socket.connect(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), params.getPort()), vConnectTimeoutMillis);
|
||||||
localhostCheckState = LocalhostCheckState.FOUND;
|
localhostCheckState = LocalhostCheckState.FOUND;
|
||||||
Closeables.close(socket, true);
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.info("Localhost peer not detected.");
|
log.info("Localhost peer not detected.");
|
||||||
|
@ -26,6 +26,7 @@ import com.google.bitcoin.testing.TestWithPeerGroup;
|
|||||||
import com.google.bitcoin.utils.Threading;
|
import com.google.bitcoin.utils.Threading;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -652,7 +653,7 @@ public class PeerGroupTest extends TestWithPeerGroup {
|
|||||||
@Test
|
@Test
|
||||||
public void preferLocalPeer() throws IOException {
|
public void preferLocalPeer() throws IOException {
|
||||||
// Check that if we have a localhost port 8333 then it's used instead of the p2p network.
|
// Check that if we have a localhost port 8333 then it's used instead of the p2p network.
|
||||||
ServerSocket local = new ServerSocket(params.getPort(), 100, InetAddress.getLoopbackAddress());
|
ServerSocket local = new ServerSocket(params.getPort(), 100, InetAddresses.forString("127.0.0.1"));
|
||||||
try {
|
try {
|
||||||
peerGroup.startAsync();
|
peerGroup.startAsync();
|
||||||
peerGroup.awaitRunning();
|
peerGroup.awaitRunning();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user