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
FieldsModifier and TypeFieldDescriptionprotected final NetworkParametersprotected final List<PeerDiscovery> - 
Constructor Summary
ConstructorsConstructorDescriptionMultiplexingDiscovery(NetworkParameters params, List<PeerDiscovery> seeds) Will query the given seeds in parallel before producing a merged response. - 
Method Summary
Modifier and TypeMethodDescriptionprotected ExecutorServicestatic MultiplexingDiscoveryforServices(NetworkParameters params, long services) Builds a suitable set of peer discoveries.static MultiplexingDiscoveryforServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers) Builds a suitable set of peer discoveries.Queries the addresses.voidshutdown()Stops any discovery in progress when we want to shut down quickly. 
- 
Field Details
- 
seeds
 - 
netParams
 
 - 
 - 
Constructor Details
- 
MultiplexingDiscovery
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. If specific services are required, DNS is not used as the protocol can't handle it.- Parameters:
 params- Network to use.services- Required services as a bitmask, e.g.VersionMessage.NODE_NETWORK.
 - 
forServices
public static MultiplexingDiscovery forServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers) Builds a suitable set of peer discoveries. If specific services are required, DNS is not used as the protocol can't handle it.- Parameters:
 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 shuffled
 - 
getPeers
public List<InetSocketAddress> getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException Description copied from interface:PeerDiscoveryQueries the addresses. This method may block.- Specified by:
 getPeersin interfacePeerDiscovery- Parameters:
 services- Required services as a bitmask, e.g.VersionMessage.NODE_NETWORK.- Throws:
 PeerDiscoveryException
 - 
createExecutor
 - 
shutdown
public void shutdown()Description copied from interface:PeerDiscoveryStops any discovery in progress when we want to shut down quickly.- Specified by:
 shutdownin interfacePeerDiscovery
 
 -