mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
SeedPeers: don't throw in getPeers() if service bit filtering is used
This brings SeedPeers more in line with the other peer discoveries. There is no guarantee for filtering.
This commit is contained in:
parent
3fffeee295
commit
fe72abe8fc
1 changed files with 10 additions and 1 deletions
|
@ -18,6 +18,8 @@ package org.bitcoinj.net.discovery;
|
||||||
|
|
||||||
import org.bitcoinj.base.utils.ByteUtils;
|
import org.bitcoinj.base.utils.ByteUtils;
|
||||||
import org.bitcoinj.core.NetworkParameters;
|
import org.bitcoinj.core.NetworkParameters;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -37,6 +39,8 @@ public class SeedPeers implements PeerDiscovery {
|
||||||
private int[] seedAddrs;
|
private int[] seedAddrs;
|
||||||
private int pnseedIndex;
|
private int pnseedIndex;
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SeedPeers.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports finding peers by IP addresses
|
* Supports finding peers by IP addresses
|
||||||
*
|
*
|
||||||
|
@ -85,11 +89,16 @@ public class SeedPeers implements PeerDiscovery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the Bitcoin nodes within the list.
|
* Returns all the Bitcoin nodes within the list.
|
||||||
|
*
|
||||||
|
* @param services ignored
|
||||||
|
* @param timeoutValue ignored
|
||||||
|
* @param timeoutUnit ignored
|
||||||
|
* @return the pre-determined list of peers
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<InetSocketAddress> getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
|
public List<InetSocketAddress> getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
|
||||||
if (services != 0)
|
if (services != 0)
|
||||||
throw new PeerDiscoveryException("Pre-determined peers cannot be filtered by services: " + services);
|
log.info("Pre-determined peers cannot be filtered by services: {}", services);
|
||||||
try {
|
try {
|
||||||
return allPeers();
|
return allPeers();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue