Package org.bitcoinj.net.discovery
Class MultiplexingDiscovery
- java.lang.Object
-
- org.bitcoinj.net.discovery.MultiplexingDiscovery
-
- All Implemented Interfaces:
PeerDiscovery
- Direct Known Subclasses:
DnsDiscovery
public class MultiplexingDiscovery extends java.lang.Object implements PeerDiscovery
MultiplexingDiscovery queries multiple PeerDiscovery objects, optionally shuffles their responses and then returns the results, thus selecting randomly between them and reducing the influence of any particular seed. Any that don't respond within the timeout are ignored. Backends are queried in parallel or serially. Backends may block.
-
-
Field Summary
Fields Modifier and Type Field Description protected NetworkParameters
netParams
Deprecated.protected java.util.List<PeerDiscovery>
seeds
-
Constructor Summary
Constructors Constructor Description MultiplexingDiscovery(Network network, java.util.List<PeerDiscovery> seeds)
Will query the given seeds in parallel before producing a merged response.MultiplexingDiscovery(NetworkParameters params, java.util.List<PeerDiscovery> seeds)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.util.concurrent.ExecutorService
createExecutor()
static MultiplexingDiscovery
forServices(Network network, long services)
Builds a suitable set of peer discoveries.static MultiplexingDiscovery
forServices(Network network, long services, boolean parallelQueries, boolean shufflePeers)
Builds a suitable set of peer discoveries.static MultiplexingDiscovery
forServices(NetworkParameters params, long services)
Deprecated.static MultiplexingDiscovery
forServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers)
Deprecated.java.util.List<java.net.InetSocketAddress>
getPeers(long services, java.time.Duration timeout)
Queries for addresses.void
shutdown()
Stops any discovery in progress when we want to shut down quickly.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bitcoinj.net.discovery.PeerDiscovery
getPeers
-
-
-
-
Field Detail
-
seeds
protected final java.util.List<PeerDiscovery> seeds
-
netParams
@Deprecated protected final NetworkParameters netParams
Deprecated.
-
-
Constructor Detail
-
MultiplexingDiscovery
public MultiplexingDiscovery(Network network, java.util.List<PeerDiscovery> seeds)
Will query the given seeds in parallel before producing a merged response.- Parameters:
network
- The network we are querying forseeds
- Sources to query in parallel
-
MultiplexingDiscovery
@Deprecated public MultiplexingDiscovery(NetworkParameters params, java.util.List<PeerDiscovery> seeds)
Deprecated.Will query the given seeds in parallel before producing a merged response.
-
-
Method Detail
-
forServices
public static MultiplexingDiscovery forServices(Network network, long services)
Builds a suitable set of peer discoveries. Will query them in parallel before producing a merged response.- Parameters:
network
- Network to use.services
- Required services as a bitmask, e.g.Services.NODE_NETWORK
.
-
forServices
public static MultiplexingDiscovery forServices(Network network, long services, boolean parallelQueries, boolean shufflePeers)
Builds a suitable set of peer discoveries.- Parameters:
network
- Network to use.services
- Required services as a bitmask, e.g.Services.NODE_NETWORK
.parallelQueries
- When true, seeds are queried in parallelshufflePeers
- When true, queried peers are shuffled
-
forServices
@Deprecated public static MultiplexingDiscovery forServices(NetworkParameters params, long services)
Deprecated.
-
forServices
@Deprecated public static MultiplexingDiscovery forServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers)
Deprecated.
-
getPeers
public java.util.List<java.net.InetSocketAddress> getPeers(long services, java.time.Duration timeout) throws PeerDiscoveryException
Description copied from interface:PeerDiscovery
Queries for addresses. This method may block.- Specified by:
getPeers
in interfacePeerDiscovery
- Parameters:
services
- required services as a bitmask, e.g.Services.NODE_NETWORK
timeout
- query timeout- Returns:
- found addresses
- Throws:
PeerDiscoveryException
-
createExecutor
protected java.util.concurrent.ExecutorService createExecutor()
-
shutdown
public void shutdown()
Description copied from interface:PeerDiscovery
Stops any discovery in progress when we want to shut down quickly.- Specified by:
shutdown
in interfacePeerDiscovery
-
-