Package org.bitcoinj.net.discovery
Class MultiplexingDiscovery
java.lang.Object
org.bitcoinj.net.discovery.MultiplexingDiscovery
- All Implemented Interfaces:
PeerDiscovery
- Direct Known Subclasses:
DnsDiscovery
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
Modifier and TypeFieldDescriptionprotected final NetworkParameters
Deprecated.protected final List<PeerDiscovery>
-
Constructor Summary
ConstructorDescriptionMultiplexingDiscovery
(Network network, List<PeerDiscovery> seeds) Will query the given seeds in parallel before producing a merged response.MultiplexingDiscovery
(NetworkParameters params, List<PeerDiscovery> seeds) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected ExecutorService
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.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 Details
-
seeds
-
netParams
Deprecated.
-
-
Constructor Details
-
MultiplexingDiscovery
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.Will query the given seeds in parallel before producing a merged response.
-
-
Method Details
-
forServices
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 List<InetSocketAddress> getPeers(long services, 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
-
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
-
MultiplexingDiscovery(Network, List)