public class MultiplexingDiscovery extends java.lang.Object implements PeerDiscovery
Modifier and Type | Field and Description |
---|---|
protected NetworkParameters |
netParams |
protected java.util.List<PeerDiscovery> |
seeds |
Constructor and Description |
---|
MultiplexingDiscovery(NetworkParameters params,
java.util.List<PeerDiscovery> seeds)
Will query the given seeds in parallel before producing a merged response.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.concurrent.ExecutorService |
createExecutor() |
static MultiplexingDiscovery |
forServices(NetworkParameters params,
long services)
Builds a suitable set of peer discoveries.
|
static MultiplexingDiscovery |
forServices(NetworkParameters params,
long services,
boolean parallelQueries,
boolean shufflePeers)
Builds a suitable set of peer discoveries.
|
java.util.List<java.net.InetSocketAddress> |
getPeers(long services,
long timeoutValue,
java.util.concurrent.TimeUnit timeoutUnit)
Queries the addresses.
|
void |
shutdown()
Stops any discovery in progress when we want to shut down quickly.
|
protected final java.util.List<PeerDiscovery> seeds
protected final NetworkParameters netParams
public MultiplexingDiscovery(NetworkParameters params, java.util.List<PeerDiscovery> seeds)
public static MultiplexingDiscovery forServices(NetworkParameters params, long services)
params
- Network to use.services
- Required services as a bitmask, e.g. VersionMessage.NODE_NETWORK
.public static MultiplexingDiscovery forServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers)
params
- Network to use.services
- Required services as a bitmask, e.g. VersionMessage.NODE_NETWORK
.parallelQueries
- When true, seeds are queried in parallelshufflePeers
- When true, queried peers are shuffledpublic java.util.List<java.net.InetSocketAddress> getPeers(long services, long timeoutValue, java.util.concurrent.TimeUnit timeoutUnit) throws PeerDiscoveryException
PeerDiscovery
getPeers
in interface PeerDiscovery
services
- Required services as a bitmask, e.g. VersionMessage.NODE_NETWORK
.PeerDiscoveryException
protected java.util.concurrent.ExecutorService createExecutor()
public void shutdown()
PeerDiscovery
shutdown
in interface PeerDiscovery